Commit graph

15 commits

Author SHA1 Message Date
Ammarpad
0156a47d8a Fix error message in ExtensionJsonValidation test
Exception::getMessage() always returns string, so it will
never equals boolean false, so the test will always fail, but
with a confusing error message.

Bug: T274591
Change-Id: Icd10e67a70666927eca886c829a4a3b1cd7441eb
2021-02-12 20:53:11 +00:00
Ammarpad
6e2818025f Use generator function in ExtensionJsonValidationTest
Faster run time, less code.

Change-Id: I8e7ce57c0f7b958c0c36ee6ae6c6727ef8d5c76d
2021-02-12 12:05:16 +01:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Thiemo Kreuz
e4272518f7 tests: Replace PHPUnit's loose assertEquals(false) with assertFalse()
assertEquals( false, … ) still succeeds when the actual value is 0, null,
an empty string, even an empty array. All these should be reported as a
failure, I would argue.

Note this patch previously also touched assertSame( false ). I reverted
these. The only benefit would have been consistency within this codebase,
but there is no strict reason to prefer one over the other. assertFalse()
and assertSame( false ) are functionally identical.

Change-Id: Ic5f1c7d504e7249002d3184520012e03313137b4
2019-10-04 00:30:36 +00:00
Gergő Tisza
45d4e8d13a Exempt structure tests from @covers checks
@covers does not make any sense for structure tests, which either
do not cover any PHP lines (they test things like configuration or
messages), or cover lines which cannot be determined at the time
of writing the tests (e.g. they cover all classes implementing a
certain interface). Requiring @coversNothing to be manually added
for all of them is a waste of developer time.

tests/phpunit/suite.xml has forceCoversAnnotation=true so removing
the annotations will not change test coverage, these files will
still be skipped.

Change-Id: I27cb58e92341b9b1a76f109701f5bc843adbaa9b
2019-06-11 21:40:14 +00:00
Kunal Mehta
4acb7ed51c Add @coversNothing to tests that don't cover specific PHP classes
Change-Id: Idbd364561bc28547e9fac20d7a80b9a44edf14a9
2018-06-12 13:27:40 -07:00
Umherirrender
63d96c15fd build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
Change-Id: I59b59f79bbf3ce4feff3b3a20c1c31bc16370531
2018-02-17 13:29:13 +01:00
Kunal Mehta
75160bdd3b Use MediaWikiCoversValidator for tests that don't use MediaWikiTestCase
Change-Id: I8c4de7e9c72c9969088666007b54c6fd23f6cc13
2018-01-01 08:28:02 +00:00
Thiemo Mättig
3e83a50213 Remove unused imports from test classes
Validating this should be as simple as it can be: if the tests run,
this change should be fine. :-)

Change-Id: I8e4a3dfc83fdc9b8c8d7f5bbd067e088ebd2133d
2017-01-10 11:49:58 +01:00
Kunal Mehta
da68c0ae82 registration: Refactor validation logic to avoid duplication
Previously, logic to validate extension.json files was in two places:
validateRegistrationFile.php maintenance script, and the
ExtensionJsonValidationTest.php structure test. This caused duplication
as validation became more complex (e.g. usage of spdx-licenses library).

A generic ExtensionJsonValidator class now handles most of the
validation work, while the maintenance script and test case just wrap
around it for their output formats.

Change-Id: I47062a4ae19c58ee1b1f2bb4877913259bf19c8b
2016-11-30 23:04:27 -08:00
Sam Wilson
66e215baee Remove spaces after cast operators
This fixes the outstanding mis-spaced cast operators to bring them
into line with the coding standards on mediawiki.org (and with the
more common usage within this codebase).

Bug: T149545
Change-Id: Ib7bcf95bbee83d20c05f6d621ce7b4e1fb58a347
2016-10-31 13:57:39 +00:00
Kunal Mehta
f6644c07cb registration: Improve license-name validation
Our hardcoded enum list in the extension.json schema for license-name
values was incomplete and did not cover the full SPDX license identifier
specification, which includes things like "AND" for specifying multiple
licenses.

Composer already has solid code in a library to do this validation, so
let's use it! This updates both the validateRegistrationFile.php and
ExtensionJsonValidationTest.php to use the composer/spdx-licenses
library (a new development dependency) to ensure the license-name field
is a valid SPDX identifier.

Also fix a silly typo in the validateRegistrationFile script which
prevented it from running, and use ::class so it will be easier to
detect typos like that in the future.

Bug: T146862
Change-Id: Ibb8973ed7950ae81c90558f9630f73746b2aff2c
2016-09-28 20:50:48 +00:00
Florian Schmidt
0cef9623c5 Upgrade justinrainbow/json-schema to ~3.0
The release between 1.6.1 and 3.0.0 has a huge amount of code
maintenance changes, as well as internal optimization and some
"visible" changes (as well as the one mentioned in the linked
task).

However, it's a version jump over 2 major versions, which is,
by it's definition a major change ;). Nonetheless, the (for us)
important api has changed marginally: Instead of using the
JsonSchema\Uri\UriRetriever class to retrieve the schema, we now use
the $ref keyword to reference the json schema file (which also is
an internal optimization). In this way, we let the json-schema library
decide, how to resolve a ref (and the schema) instead of relying
on the UriRetriever api to be public and stable.

The versions also include various bug fixes (which, as far as I know,
doesn't apply to us).

I tested this change with various combinations of valid and invalid
extension.json schemas (version 2 as well as version 3). Given that
there were no major changes to the schema interpretation itself, and
the good test coverage of the library, there shouldn't be a high risk
because of this change.

The full list of changes can be found at:
https://github.com/justinrainbow/json-schema/compare/1.6.1...3.0.0

as well as the changelogs of the single versions:
https://github.com/justinrainbow/json-schema/releases

Bug: T141281
Depends-On: I5687286da9f7fa2bb2b84699fa43ab3c2547fe03
Change-Id: Ie37e2ebc48684783abf8d99d2f775ee6a5988da7
2016-08-23 21:22:21 +00:00
Kunal Mehta
8aa43b4df9 Add a structure test to validate all extension.json files
Adds a structure test to validate that all loaded extension.json and
skin.json files validate against the schema at
docs/extension.schema.json.

Bug: T128307
Change-Id: I2fd1caaa50c288821ab6847dc29d60e6554d9df5
2016-03-14 12:54:58 -07:00