1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 09:02:59 +00:00

Refactoring Tests (#6849)

This commit is contained in:
Gabriel Caruso 2017-11-30 12:58:10 -02:00 committed by Jordi Boggiano
parent ecb26c7b75
commit a4b220273e
9 changed files with 24 additions and 27 deletions

View file

@ -93,7 +93,7 @@ class AllFunctionalTest extends TestCase
$this->fail($proc->getOutput()); $this->fail($proc->getOutput());
} }
$this->assertTrue(file_exists(self::$pharPath)); $this->assertFileExists(self::$pharPath);
} }
/** /**

View file

@ -378,7 +378,7 @@ class AutoloadGeneratorTest extends TestCase
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5');
$this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); $this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer');
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated, even if empty."); $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty.");
} }
public function testPSRToClassMapIgnoresNonExistingDir() public function testPSRToClassMapIgnoresNonExistingDir()
@ -395,7 +395,7 @@ class AutoloadGeneratorTest extends TestCase
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8');
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated."); $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( $this->assertEquals(
array(), array(),
include $this->vendorDir.'/composer/autoload_classmap.php' include $this->vendorDir.'/composer/autoload_classmap.php'
@ -425,7 +425,7 @@ class AutoloadGeneratorTest extends TestCase
file_put_contents($this->vendorDir.'/b/b/lib/c.php', '<?php class ClassMapBaz {}'); file_put_contents($this->vendorDir.'/b/b/lib/c.php', '<?php class ClassMapBaz {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated."); $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( $this->assertEquals(
array( array(
'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php', 'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php',
@ -461,7 +461,7 @@ class AutoloadGeneratorTest extends TestCase
file_put_contents($this->vendorDir.'/b/b/src/c.php', '<?php class ClassMapBaz {}'); file_put_contents($this->vendorDir.'/b/b/src/c.php', '<?php class ClassMapBaz {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated."); $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( $this->assertEquals(
array( array(
'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php', 'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php',
@ -497,7 +497,7 @@ class AutoloadGeneratorTest extends TestCase
file_put_contents($this->vendorDir.'/c/c/foo/test.php', '<?php class ClassMapBaz {}'); file_put_contents($this->vendorDir.'/c/c/foo/test.php', '<?php class ClassMapBaz {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7');
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated."); $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( $this->assertEquals(
array( array(
'ClassMapBar' => $this->vendorDir.'/b/b/test.php', 'ClassMapBar' => $this->vendorDir.'/b/b/test.php',
@ -539,7 +539,7 @@ class AutoloadGeneratorTest extends TestCase
$this->generator->setApcu(true); $this->generator->setApcu(true);
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7');
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated."); $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( $this->assertEquals(
array( array(
'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php', 'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php',
@ -930,7 +930,7 @@ EOF;
$this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12'); $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12');
$this->assertFalse(file_exists($this->vendorDir."/composer/include_paths.php")); $this->assertFileNotExists($this->vendorDir."/composer/include_paths.php");
} }
public function testPreAndPostEventsAreDispatchedDuringAutoloadDump() public function testPreAndPostEventsAreDispatchedDuringAutoloadDump()

View file

@ -76,7 +76,7 @@ class SolverTest extends TestCase
$this->fail('Unsolvable conflict did not result in exception.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertEquals(1, count($problems)); $this->assertCount(1, $problems);
$this->assertEquals(2, $e->getCode()); $this->assertEquals(2, $e->getCode());
$this->assertEquals("\n - The requested package b could not be found in any version, there may be a typo in the package name.", $problems[0]->getPrettyString()); $this->assertEquals("\n - The requested package b could not be found in any version, there may be a typo in the package name.", $problems[0]->getPrettyString());
} }
@ -671,7 +671,7 @@ class SolverTest extends TestCase
$this->fail('Unsolvable conflict did not result in exception.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertEquals(1, count($problems)); $this->assertCount(1, $problems);
$msg = "\n"; $msg = "\n";
$msg .= " Problem 1\n"; $msg .= " Problem 1\n";
@ -700,7 +700,7 @@ class SolverTest extends TestCase
$this->fail('Unsolvable conflict did not result in exception.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertEquals(1, count($problems)); $this->assertCount(1, $problems);
// TODO assert problem properties // TODO assert problem properties
$msg = "\n"; $msg = "\n";
@ -747,7 +747,7 @@ class SolverTest extends TestCase
$this->fail('Unsolvable conflict did not result in exception.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertEquals(1, count($problems)); $this->assertCount(1, $problems);
$msg = "\n"; $msg = "\n";
$msg .= " Problem 1\n"; $msg .= " Problem 1\n";

View file

@ -47,10 +47,7 @@ class SuggestedPackagesReporterTest extends \PHPUnit_Framework_TestCase
*/ */
public function testGetPackagesEmptyByDefault() public function testGetPackagesEmptyByDefault()
{ {
$this->assertSame( $this->assertEmpty($this->suggestedPackagesReporter->getPackages());
array(),
$this->suggestedPackagesReporter->getPackages()
);
} }
/** /**

View file

@ -73,7 +73,7 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
$config = $this->dumper->dump($this->package); $config = $this->dumper->dump($this->package);
$this->assertSame(true, $config['abandoned']); $this->assertTrue($config['abandoned']);
} }
public function testDumpAbandonedReplacement() public function testDumpAbandonedReplacement()

View file

@ -23,7 +23,7 @@ class ArrayRepositoryTest extends TestCase
$repo = new ArrayRepository; $repo = new ArrayRepository;
$repo->addPackage($this->getPackage('foo', '1')); $repo->addPackage($this->getPackage('foo', '1'));
$this->assertEquals(1, count($repo)); $this->assertCount(1, $repo);
} }
public function testRemovePackage() public function testRemovePackage()
@ -34,11 +34,11 @@ class ArrayRepositoryTest extends TestCase
$repo->addPackage($this->getPackage('foo', '1')); $repo->addPackage($this->getPackage('foo', '1'));
$repo->addPackage($package); $repo->addPackage($package);
$this->assertEquals(2, count($repo)); $this->assertCount(2, $repo);
$repo->removePackage($this->getPackage('foo', '1')); $repo->removePackage($this->getPackage('foo', '1'));
$this->assertEquals(1, count($repo)); $this->assertCount(1, $repo);
$this->assertEquals(array($package), $repo->getPackages()); $this->assertEquals(array($package), $repo->getPackages());
} }
@ -77,7 +77,7 @@ class ArrayRepositoryTest extends TestCase
$repo->addPackage($alias); $repo->addPackage($alias);
$this->assertEquals(2, count($repo)); $this->assertCount(2, $repo);
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '1'))); $this->assertTrue($repo->hasPackage($this->getPackage('foo', '1')));
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '2'))); $this->assertTrue($repo->hasPackage($this->getPackage('foo', '2')));
} }

View file

@ -36,7 +36,7 @@ class FilesystemRepositoryTest extends TestCase
$packages = $repository->getPackages(); $packages = $repository->getPackages();
$this->assertSame(1, count($packages)); $this->assertCount(1, $packages);
$this->assertSame('package1', $packages[0]->getName()); $this->assertSame('package1', $packages[0]->getName());
$this->assertSame('1.0.0.0-beta', $packages[0]->getVersion()); $this->assertSame('1.0.0.0-beta', $packages[0]->getVersion());
$this->assertSame('vendor', $packages[0]->getType()); $this->assertSame('vendor', $packages[0]->getType());

View file

@ -45,7 +45,7 @@ class ChannelReaderTest extends TestCase
$this->assertEquals('MDB2', $packages[2]->getPackageName()); $this->assertEquals('MDB2', $packages[2]->getPackageName());
$mdb2releases = $packages[2]->getReleases(); $mdb2releases = $packages[2]->getReleases();
$this->assertEquals(9, count($mdb2releases['2.4.0']->getDependencyInfo()->getOptionals())); $this->assertCount(9, $mdb2releases['2.4.0']->getDependencyInfo()->getOptionals());
} }
public function testShouldSelectCorrectReader() public function testShouldSelectCorrectReader()

View file

@ -168,7 +168,7 @@ class FilesystemTest extends TestCase
$fs = new Filesystem; $fs = new Filesystem;
$this->assertTrue($fs->removeDirectoryPhp($this->workingDir)); $this->assertTrue($fs->removeDirectoryPhp($this->workingDir));
$this->assertFalse(file_exists($this->workingDir . "/level1/level2/hello.txt")); $this->assertFileNotExists($this->workingDir . "/level1/level2/hello.txt");
} }
public function testFileSize() public function testFileSize()
@ -247,7 +247,7 @@ class FilesystemTest extends TestCase
$fs = new Filesystem(); $fs = new Filesystem();
$result = $fs->unlink($symlinked); $result = $fs->unlink($symlinked);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFalse(file_exists($symlinked)); $this->assertFileNotExists($symlinked);
} }
/** /**
@ -279,8 +279,8 @@ class FilesystemTest extends TestCase
$result = $fs->removeDirectory($symlinkedTrailingSlash); $result = $fs->removeDirectory($symlinkedTrailingSlash);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFalse(file_exists($symlinkedTrailingSlash)); $this->assertFileNotExists($symlinkedTrailingSlash);
$this->assertFalse(file_exists($symlinked)); $this->assertFileNotExists($symlinked);
} }
public function testJunctions() public function testJunctions()