| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
use MediaWiki\Composer\LockFileChecker; |
| 22 |
use Wikimedia\Composer\ComposerJson; |
| 23 |
use Wikimedia\Composer\ComposerLock; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
class LockFileCheckerTest extends MediaWikiIntegrationTestCase { |
| 29 |
|
| 30 |
private const FIXTURE_DIRECTORY = MW_INSTALL_PATH . '/tests/phpunit/data/LockFileChecker'; |
| 31 |
|
| 32 |
public function testOk() { |
| 33 |
$json = new ComposerJson( self::FIXTURE_DIRECTORY . '/composer-testcase1.json' ); |
| 34 |
$lock = new ComposerLock( self::FIXTURE_DIRECTORY . '/composer-testcase1.lock' ); |
| 35 |
$checker = new LockFileChecker( $json, $lock ); |
| 36 |
$errors = $checker->check(); |
| 37 |
$this->assertNull( $errors ); |
| 38 |
} |
| 39 |
|
| 40 |
public function testOutdated() { |
| 41 |
$json = new ComposerJson( self::FIXTURE_DIRECTORY . '/composer-testcase2.json' ); |
| 42 |
$lock = new ComposerLock( self::FIXTURE_DIRECTORY . '/composer-testcase2.lock' ); |
| 43 |
$checker = new LockFileChecker( $json, $lock ); |
| 44 |
$errors = $checker->check(); |
| 45 |
$this->assertArrayEquals( [ |
| 46 |
'wikimedia/relpath: 2.9.9 installed, 3.0.0 required.', |
| 47 |
], $errors ); |
| 48 |
} |
| 49 |
|
| 50 |
public function testNotInstalled() { |
| 51 |
$json = new ComposerJson( self::FIXTURE_DIRECTORY . '/composer-testcase3.json' ); |
| 52 |
$lock = new ComposerLock( self::FIXTURE_DIRECTORY . '/composer-testcase3.lock' ); |
| 53 |
$checker = new LockFileChecker( $json, $lock ); |
| 54 |
$errors = $checker->check(); |
| 55 |
$this->assertArrayEquals( [ |
| 56 |
'wikimedia/relpath: 2.9.9 installed, 3.0.0 required.', |
| 57 |
'wikimedia/at-ease: not installed, 2.1.0 required.', |
| 58 |
], $errors ); |
| 59 |
} |
| 60 |
} |