Tweak and fix some more phpstan reports

main
Jordi Boggiano 5 years ago
parent a062cd1a31
commit 799717f102
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -29,9 +29,11 @@ parameters:
- '~^Undefined variable: \$vendorDir$~' - '~^Undefined variable: \$vendorDir$~'
- '~^Undefined variable: \$baseDir$~' - '~^Undefined variable: \$baseDir$~'
# variable defined in eval
- '~^Undefined variable: \$res$~'
# always checked whether the class exists # always checked whether the class exists
- '~^Instantiated class Symfony\\Component\\Console\\Terminal not found\.$~' - '~^Call to an undefined static method Symfony\\Component\\Process\\Process::fromShellCommandline\(\).$~'
- '~^Class Symfony\\Component\\Console\\Input\\StreamableInputInterface not found\.$~'
# parent call in test mocks # parent call in test mocks
- '~^Composer\\Test\\Mock\\HttpDownloaderMock::__construct\(\) does not call parent constructor from Composer\\Util\\HttpDownloader\.$~' - '~^Composer\\Test\\Mock\\HttpDownloaderMock::__construct\(\) does not call parent constructor from Composer\\Util\\HttpDownloader\.$~'

@ -40,7 +40,7 @@ class SolverTest extends TestCase
$this->repo = new ArrayRepository; $this->repo = new ArrayRepository;
$this->repoInstalled = new InstalledArrayRepository; $this->repoInstalled = new InstalledArrayRepository;
$this->request = new Request($this->repoSet); $this->request = new Request();
$this->policy = new DefaultPolicy; $this->policy = new DefaultPolicy;
} }

@ -129,7 +129,7 @@ class PerforceDownloaderTest extends TestCase
$this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref)); $this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
$this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref)); $this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref));
$perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec'); $perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
$perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock(); $perforce = $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
$perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath)); $perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
$perforce->expects($this->at(1))->method('setStream')->with($this->equalTo($ref)); $perforce->expects($this->at(1))->method('setStream')->with($this->equalTo($ref));
$perforce->expects($this->at(2))->method('p4Login'); $perforce->expects($this->at(2))->method('p4Login');
@ -152,7 +152,7 @@ class PerforceDownloaderTest extends TestCase
$this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref)); $this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
$this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref)); $this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref));
$perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec'); $perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
$perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock(); $perforce = $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
$perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath)); $perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
$perforce->expects($this->at(1))->method('setStream')->with($this->equalTo($ref)); $perforce->expects($this->at(1))->method('setStream')->with($this->equalTo($ref));
$perforce->expects($this->at(2))->method('p4Login'); $perforce->expects($this->at(2))->method('p4Login');

@ -108,7 +108,7 @@ class PerforceDriverTest extends TestCase
{ {
$methods = array('p4login', 'checkStream', 'writeP4ClientSpec', 'connectClient', 'getComposerInformation', 'cleanupClientSpec'); $methods = array('p4login', 'checkStream', 'writeP4ClientSpec', 'connectClient', 'getComposerInformation', 'cleanupClientSpec');
return $this->getMockBuilder('Composer\Util\Perforce', $methods)->disableOriginalConstructor()->getMock(); return $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
} }
public function testInitializeCapturesVariablesFromRepoConfig() public function testInitializeCapturesVariablesFromRepoConfig()

@ -32,17 +32,18 @@ class VcsRepositoryTest extends TestCase
protected function initialize() protected function initialize()
{ {
$oldCwd = getcwd();
self::$composerHome = $this->getUniqueTmpDirectory();
self::$gitRepo = $this->getUniqueTmpDirectory();
$locator = new ExecutableFinder(); $locator = new ExecutableFinder();
if (!$locator->find('git')) { if (!$locator->find('git')) {
$this->skipped = 'This test needs a git binary in the PATH to be able to run'; $this->skipped = 'This test needs a git binary in the PATH to be able to run';
return; return;
} }
if (!@mkdir(self::$gitRepo) || !@chdir(self::$gitRepo)) {
$oldCwd = getcwd();
self::$composerHome = $this->getUniqueTmpDirectory();
self::$gitRepo = $this->getUniqueTmpDirectory();
if (!@chdir(self::$gitRepo)) {
$this->skipped = 'Could not create and move into the temp git repo '.self::$gitRepo; $this->skipped = 'Could not create and move into the temp git repo '.self::$gitRepo;
return; return;
@ -60,6 +61,7 @@ class VcsRepositoryTest extends TestCase
$exec('git init'); $exec('git init');
$exec('git config user.email composertest@example.org'); $exec('git config user.email composertest@example.org');
$exec('git config user.name ComposerTest'); $exec('git config user.name ComposerTest');
$exec('git config commit.gpgsign false');
touch('foo'); touch('foo');
$exec('git add foo'); $exec('git add foo');
$exec('git commit -m init'); $exec('git commit -m init');
@ -150,7 +152,8 @@ class VcsRepositoryTest extends TestCase
'home' => self::$composerHome, 'home' => self::$composerHome,
), ),
)); ));
$repo = new VcsRepository(array('url' => self::$gitRepo, 'type' => 'vcs'), new NullIO, $config); $httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock();
$repo = new VcsRepository(array('url' => self::$gitRepo, 'type' => 'vcs'), new NullIO, $config, $httpDownloader);
$packages = $repo->getPackages(); $packages = $repo->getPackages();
$dumper = new ArrayDumper(); $dumper = new ArrayDumper();

Loading…
Cancel
Save