diff options
Diffstat (limited to 'www/wiki/tests/phpunit/includes/libs/composer')
3 files changed, 662 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/libs/composer/ComposerInstalledTest.php b/www/wiki/tests/phpunit/includes/libs/composer/ComposerInstalledTest.php new file mode 100644 index 00000000..05ae2a37 --- /dev/null +++ b/www/wiki/tests/phpunit/includes/libs/composer/ComposerInstalledTest.php @@ -0,0 +1,499 @@ +<?php + +class ComposerInstalledTest extends MediaWikiTestCase { + + private $installed; + + public function setUp() { + parent::setUp(); + global $IP; + $this->installed = "$IP/tests/phpunit/data/composer/installed.json"; + } + + /** + * @covers ComposerInstalled::__construct + * @covers ComposerInstalled::getInstalledDependencies + */ + public function testGetInstalledDependencies() { + $installed = new ComposerInstalled( $this->installed ); + $this->assertArrayEquals( [ + 'leafo/lessphp' => [ + 'version' => '0.5.0', + 'type' => 'library', + 'licenses' => [ 'MIT', 'GPL-3.0-only' ], + 'authors' => [ + [ + 'name' => 'Leaf Corcoran', + 'email' => 'leafot@gmail.com', + 'homepage' => 'http://leafo.net', + ], + ], + 'description' => 'lessphp is a compiler for LESS written in PHP.', + ], + 'psr/log' => [ + 'version' => '1.0.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'PHP-FIG', + 'homepage' => 'http://www.php-fig.org/', + ], + ], + 'description' => 'Common interface for logging libraries', + ], + 'cssjanus/cssjanus' => [ + 'version' => '1.1.1', + 'type' => 'library', + 'licenses' => [ 'Apache-2.0' ], + 'authors' => [ + ], + 'description' => 'Convert CSS stylesheets between left-to-right ' . + 'and right-to-left.', + ], + 'cdb/cdb' => [ + 'version' => '1.0.0', + 'type' => 'library', + 'licenses' => [ 'GPLv2' ], + 'authors' => [ + [ + 'name' => 'Tim Starling', + 'email' => 'tstarling@wikimedia.org', + ], + [ + 'name' => 'Chad Horohoe', + 'email' => 'chad@wikimedia.org', + ], + ], + 'description' => 'Constant Database (CDB) wrapper library for PHP. ' . + 'Provides pure-PHP fallback when dba_* functions are absent.', + ], + 'sebastian/version' => [ + 'version' => '2.0.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + 'role' => 'lead', + ], + ], + 'description' => 'Library that helps with managing the version ' . + 'number of Git-hosted PHP projects', + ], + 'sebastian/resource-operations' => [ + 'version' => '1.0.0', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Provides a list of PHP built-in functions that ' . + 'operate on resources', + ], + 'sebastian/recursion-context' => [ + 'version' => '3.0.0', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Jeff Welch', + 'email' => 'whatthejeff@gmail.com', + ], + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + [ + 'name' => 'Adam Harvey', + 'email' => 'aharvey@php.net', + ], + ], + 'description' => 'Provides functionality to recursively process PHP ' . + 'variables', + ], + 'sebastian/object-reflector' => [ + 'version' => '1.1.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Allows reflection of object attributes, including ' . + 'inherited and non-public ones', + ], + 'sebastian/object-enumerator' => [ + 'version' => '3.0.3', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Traverses array structures and object graphs ' . + 'to enumerate all referenced objects', + ], + 'sebastian/global-state' => [ + 'version' => '2.0.0', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Snapshotting of global state', + ], + 'sebastian/exporter' => [ + 'version' => '3.1.0', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Jeff Welch', + 'email' => 'whatthejeff@gmail.com', + ], + [ + 'name' => 'Volker Dusch', + 'email' => 'github@wallbash.com', + ], + [ + 'name' => 'Bernhard Schussek', + 'email' => 'bschussek@2bepublished.at', + ], + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + [ + 'name' => 'Adam Harvey', + 'email' => 'aharvey@php.net', + ], + ], + 'description' => 'Provides the functionality to export PHP ' . + 'variables for visualization', + ], + 'sebastian/environment' => [ + 'version' => '3.1.0', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Provides functionality to handle HHVM/PHP ' . + 'environments', + ], + 'sebastian/diff' => [ + 'version' => '2.0.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Kore Nordmann', + 'email' => 'mail@kore-nordmann.de', + ], + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Diff implementation', + ], + 'sebastian/comparator' => [ + 'version' => '2.1.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Jeff Welch', + 'email' => 'whatthejeff@gmail.com', + ], + [ + 'name' => 'Volker Dusch', + 'email' => 'github@wallbash.com', + ], + [ + 'name' => 'Bernhard Schussek', + 'email' => 'bschussek@2bepublished.at', + ], + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Provides the functionality to compare PHP ' . + 'values for equality', + ], + 'doctrine/instantiator' => [ + 'version' => '1.1.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'Marco Pivetta', + 'email' => 'ocramius@gmail.com', + 'homepage' => 'http://ocramius.github.com/', + ], + ], + 'description' => 'A small, lightweight utility to instantiate ' . + 'objects in PHP without invoking their constructors', + ], + 'phpunit/php-text-template' => [ + 'version' => '1.2.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + 'role' => 'lead', + ], + ], + 'description' => 'Simple template engine.', + ], + 'phpunit/phpunit-mock-objects' => [ + 'version' => '5.0.6', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + 'role' => 'lead', + ], + ], + 'description' => 'Mock Object library for PHPUnit', + ], + 'phpunit/php-timer' => [ + 'version' => '1.0.9', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sb@sebastian-bergmann.de', + 'role' => 'lead', + ], + ], + 'description' => 'Utility class for timing', + ], + 'phpunit/php-file-iterator' => [ + 'version' => '1.4.5', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sb@sebastian-bergmann.de', + 'role' => 'lead', + ], + ], + 'description' => 'FilterIterator implementation that filters ' . + 'files based on a list of suffixes.', + ], + 'theseer/tokenizer' => [ + 'version' => '1.1.0', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Arne Blankerts', + 'email' => 'arne@blankerts.de', + 'role' => 'Developer', + ], + ], + 'description' => 'A small library for converting tokenized PHP ' . + 'source code into XML and potentially other formats', + ], + 'sebastian/code-unit-reverse-lookup' => [ + 'version' => '1.0.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Looks up which function or method a line of ' . + 'code belongs to', + ], + 'phpunit/php-token-stream' => [ + 'version' => '2.0.2', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + ], + ], + 'description' => 'Wrapper around PHP\'s tokenizer extension.', + ], + 'phpunit/php-code-coverage' => [ + 'version' => '5.3.0', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + 'role' => 'lead', + ], + ], + 'description' => 'Library that provides collection, processing, ' . + 'and rendering functionality for PHP code coverage information.', + ], + 'webmozart/assert' => [ + 'version' => '1.2.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'Bernhard Schussek', + 'email' => 'bschussek@gmail.com', + ], + ], + 'description' => 'Assertions to validate method input/output with ' . + 'nice error messages.', + ], + 'phpdocumentor/reflection-common' => [ + 'version' => '1.0.1', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'Jaap van Otterdijk', + 'email' => 'opensource@ijaap.nl', + ], + ], + 'description' => 'Common reflection classes used by phpdocumentor to ' . + 'reflect the code structure', + ], + 'phpdocumentor/type-resolver' => [ + 'version' => '0.4.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'Mike van Riel', + 'email' => 'me@mikevanriel.com', + ], + ], + 'description' => '', + ], + 'phpdocumentor/reflection-docblock' => [ + 'version' => '4.2.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'Mike van Riel', + 'email' => 'me@mikevanriel.com', + ], + ], + 'description' => 'With this component, a library can provide support for ' . + 'annotations via DocBlocks or otherwise retrieve information that ' . + 'is embedded in a DocBlock.', + ], + 'phpspec/prophecy' => [ + 'version' => '1.7.3', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'Konstantin Kudryashov', + 'email' => 'ever.zet@gmail.com', + 'homepage' => 'http://everzet.com', + ], + [ + 'name' => 'Marcello Duarte', + 'email' => 'marcello.duarte@gmail.com', + ], + ], + 'description' => 'Highly opinionated mocking framework for PHP 5.3+', + ], + 'phar-io/version' => [ + 'version' => '1.0.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Arne Blankerts', + 'email' => 'arne@blankerts.de', + 'role' => 'Developer', + ], + [ + 'name' => 'Sebastian Heuer', + 'email' => 'sebastian@phpeople.de', + 'role' => 'Developer', + ], + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + 'role' => 'Developer', + ], + ], + 'description' => 'Library for handling version information and constraints', + ], + 'phar-io/manifest' => [ + 'version' => '1.0.1', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Arne Blankerts', + 'email' => 'arne@blankerts.de', + 'role' => 'Developer', + ], + [ + 'name' => 'Sebastian Heuer', + 'email' => 'sebastian@phpeople.de', + 'role' => 'Developer', + ], + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + 'role' => 'Developer', + ], + ], + 'description' => 'Component for reading phar.io manifest ' . + 'information from a PHP Archive (PHAR)', + ], + 'myclabs/deep-copy' => [ + 'version' => '1.7.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + ], + 'description' => 'Create deep copies (clones) of your objects', + ], + 'phpunit/phpunit' => [ + 'version' => '6.5.5', + 'type' => 'library', + 'licenses' => [ 'BSD-3-Clause' ], + 'authors' => [ + [ + 'name' => 'Sebastian Bergmann', + 'email' => 'sebastian@phpunit.de', + 'role' => 'lead', + ], + ], + 'description' => 'The PHP Unit Testing framework.', + ], + ], $installed->getInstalledDependencies(), false, true ); + } +} diff --git a/www/wiki/tests/phpunit/includes/libs/composer/ComposerJsonTest.php b/www/wiki/tests/phpunit/includes/libs/composer/ComposerJsonTest.php new file mode 100644 index 00000000..ded5f8fe --- /dev/null +++ b/www/wiki/tests/phpunit/includes/libs/composer/ComposerJsonTest.php @@ -0,0 +1,42 @@ +<?php + +class ComposerJsonTest extends MediaWikiTestCase { + + private $json, $json2; + + public function setUp() { + parent::setUp(); + global $IP; + $this->json = "$IP/tests/phpunit/data/composer/composer.json"; + $this->json2 = "$IP/tests/phpunit/data/composer/new-composer.json"; + } + + /** + * @covers ComposerJson::__construct + * @covers ComposerJson::getRequiredDependencies + */ + public function testGetRequiredDependencies() { + $json = new ComposerJson( $this->json ); + $this->assertArrayEquals( [ + 'cdb/cdb' => '1.0.0', + 'cssjanus/cssjanus' => '1.1.1', + 'leafo/lessphp' => '0.5.0', + 'psr/log' => '1.0.0', + ], $json->getRequiredDependencies(), false, true ); + } + + public static function provideNormalizeVersion() { + return [ + [ 'v1.0.0', '1.0.0' ], + [ '0.0.5', '0.0.5' ], + ]; + } + + /** + * @dataProvider provideNormalizeVersion + * @covers ComposerJson::normalizeVersion + */ + public function testNormalizeVersion( $input, $expected ) { + $this->assertEquals( $expected, ComposerJson::normalizeVersion( $input ) ); + } +} diff --git a/www/wiki/tests/phpunit/includes/libs/composer/ComposerLockTest.php b/www/wiki/tests/phpunit/includes/libs/composer/ComposerLockTest.php new file mode 100644 index 00000000..dc81e1d3 --- /dev/null +++ b/www/wiki/tests/phpunit/includes/libs/composer/ComposerLockTest.php @@ -0,0 +1,121 @@ +<?php + +class ComposerLockTest extends MediaWikiTestCase { + + private $lock; + + public function setUp() { + parent::setUp(); + global $IP; + $this->lock = "$IP/tests/phpunit/data/composer/composer.lock"; + } + + /** + * @covers ComposerLock::__construct + * @covers ComposerLock::getInstalledDependencies + */ + public function testGetInstalledDependencies() { + $lock = new ComposerLock( $this->lock ); + $this->assertArrayEquals( [ + 'wikimedia/cdb' => [ + 'version' => '1.0.1', + 'type' => 'library', + 'licenses' => [ 'GPL-2.0-only' ], + 'authors' => [ + [ + 'name' => 'Tim Starling', + 'email' => 'tstarling@wikimedia.org', + ], + [ + 'name' => 'Chad Horohoe', + 'email' => 'chad@wikimedia.org', + ], + ], + 'description' => 'Constant Database (CDB) wrapper library for PHP. '. + 'Provides pure-PHP fallback when dba_* functions are absent.', + ], + 'cssjanus/cssjanus' => [ + 'version' => '1.1.1', + 'type' => 'library', + 'licenses' => [ 'Apache-2.0' ], + 'authors' => [], + 'description' => 'Convert CSS stylesheets between left-to-right and right-to-left.', + ], + 'leafo/lessphp' => [ + 'version' => '0.5.0', + 'type' => 'library', + 'licenses' => [ 'MIT', 'GPL-3.0-only' ], + 'authors' => [ + [ + 'name' => 'Leaf Corcoran', + 'email' => 'leafot@gmail.com', + 'homepage' => 'http://leafo.net', + ], + ], + 'description' => 'lessphp is a compiler for LESS written in PHP.', + ], + 'psr/log' => [ + 'version' => '1.0.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'PHP-FIG', + 'homepage' => 'http://www.php-fig.org/', + ], + ], + 'description' => 'Common interface for logging libraries', + ], + 'oojs/oojs-ui' => [ + 'version' => '0.6.0', + 'type' => 'library', + 'licenses' => [ 'MIT' ], + 'authors' => [], + 'description' => '', + ], + 'composer/installers' => [ + 'version' => '1.0.19', + 'type' => 'composer-installer', + 'licenses' => [ 'MIT' ], + 'authors' => [ + [ + 'name' => 'Kyle Robinson Young', + 'email' => 'kyle@dontkry.com', + 'homepage' => 'https://github.com/shama', + ], + ], + 'description' => 'A multi-framework Composer library installer', + ], + 'mediawiki/translate' => [ + 'version' => '2014.12', + 'type' => 'mediawiki-extension', + 'licenses' => [ 'GPL-2.0-or-later' ], + 'authors' => [ + [ + 'name' => 'Niklas Laxström', + 'email' => 'niklas.laxstrom@gmail.com', + 'role' => 'Lead nitpicker', + ], + [ + 'name' => 'Siebrand Mazeland', + 'email' => 's.mazeland@xs4all.nl', + 'role' => 'Developer', + ], + ], + 'description' => 'The only standard solution to translate any kind ' . + 'of text with an avant-garde web interface within MediaWiki, ' . + 'including your documentation and software', + ], + 'mediawiki/universal-language-selector' => [ + 'version' => '2014.12', + 'type' => 'mediawiki-extension', + 'licenses' => [ 'GPL-2.0-or-later', 'MIT' ], + 'authors' => [], + 'description' => 'The primary aim is to allow users to select a language ' . + 'and configure its support in an easy way. ' . + 'Main features are language selection, input methods and web fonts.', + ], + ], $lock->getInstalledDependencies(), false, true ); + } + +} |