public function testPostPackageUninstallDoesNothingIfModuleNotInConfig() { FileInfoStub::defineFile('config/application.config.php', \file_get_contents(__DIR__ . '/TestAsset/application.config.php')); $package = $this->prophesize(PackageInterface::class); $package->getName()->willReturn('some/module'); $package->getExtra()->willReturn(['zf' => ['module' => 'Some\\Module']]); $operation = $this->prophesize(InstallOperation::class); $operation->getPackage()->willReturn($package->reveal()); $io = $this->prophesize(IOInterface::class); $io->write(Argument::type('string'))->shouldBeCalledTimes(2); $event = $this->prophesize(PackageEvent::class); $event->isDevMode()->willReturn(true); $event->getOperation()->willReturn($operation->reveal()); $event->getIO()->willReturn($io->reveal()); $this->assertNull(ComponentInstaller::postPackageUninstall($event->reveal())); $this->assertGreaterThan(0, FileInfoStub::getInvocationCount('exists')); $this->assertGreaterThan(0, FileInfoStub::getInvocationCount('get')); $this->assertSame(0, FileInfoStub::getInvocationCount('put')); }
public function testPrependComponentAndAppendModule() { $this->createApplicationConfig('<' . "?php\nreturn [\n 'modules' => [\n 'SomeApplication',\n ]\n];"); $package = $this->prophesize(PackageInterface::class); $package->getAutoload()->willReturn([]); $package->getName()->willReturn('some/package'); $package->getExtra()->willReturn(['zf' => ['component' => 'Some\\Component', 'module' => 'Some\\Module']]); $operation = $this->prophesize(InstallOperation::class); $operation->getPackage()->willReturn($package->reveal()); $event = $this->prophesize(PackageEvent::class); $event->isDevMode()->willReturn(true); $event->getOperation()->willReturn($operation->reveal()); $this->io->ask(Argument::that(function ($argument) { if (!is_array($argument)) { return false; } if (!strstr($argument[0], "Please select which config file you wish to inject 'Some\\Module' into")) { return false; } if (!strstr($argument[1], 'Do not inject')) { return false; } if (!strstr($argument[2], 'application.config.php')) { return false; } return true; }), 0)->willReturn(1); $this->io->ask(Argument::that(function ($argument) { if (!is_array($argument)) { return false; } if (!strstr($argument[0], "Please select which config file you wish to inject 'Some\\Component' into")) { return false; } if (!strstr($argument[1], 'Do not inject')) { return false; } if (!strstr($argument[2], 'application.config.php')) { return false; } return true; }), 0)->willReturn(1); $this->io->ask(Argument::that(function ($argument) { if (!is_array($argument)) { return false; } if (!strstr($argument[0], 'Remember')) { return false; } return true; }), 'n')->willReturn('n'); $this->io->write(Argument::that(function ($argument) { return strstr($argument, 'Installing Some\\Module from package some/package'); }))->shouldBeCalled(); $this->io->write(Argument::that(function ($argument) { return strstr($argument, 'Installing Some\\Component from package some/package'); }))->shouldBeCalled(); $this->assertNull($this->installer->onPostPackageInstall($event->reveal())); $config = (include vfsStream::url('project/config/application.config.php')); $modules = $config['modules']; $this->assertEquals(['Some\\Component', 'SomeApplication', 'Some\\Module'], $modules); }