Debian Codegraph @

tests/phpunit/integration/includes/composer/LockFileCheckerTest.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 use MediaWiki\Composer\LockFileChecker;
22 use Wikimedia\Composer\ComposerJson;
23 use Wikimedia\Composer\ComposerLock;
24
25 /**
26 * @covers \MediaWiki\Composer\LockFileChecker
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 }