예제 #1
0
 public function testDoNotSetBootstrapFileIfAlreadySet()
 {
     $listeners = $this->plugin->getSubscribedEvents();
     $this->assertArrayHasKey(ScriptEvents::POST_AUTOLOAD_DUMP, $listeners);
     $listener = $listeners[ScriptEvents::POST_AUTOLOAD_DUMP];
     $event = new CommandEvent(ScriptEvents::POST_AUTOLOAD_DUMP, $this->composer, $this->io);
     $this->io->expects($this->exactly(2))->method('write');
     $this->puliRunner->expects($this->at(2))->method('run')->with("config 'bootstrap-file' --parsed")->willReturn("my/bootstrap-file.php\n");
     $this->puliRunner->expects($this->exactly(3))->method('run');
     $this->plugin->{$listener}($event);
 }
 public function testInsertFactoryConstantIntoAutoload()
 {
     $listeners = $this->plugin->getSubscribedEvents();
     $this->assertArrayHasKey(ScriptEvents::POST_AUTOLOAD_DUMP, $listeners);
     $listener = $listeners[ScriptEvents::POST_AUTOLOAD_DUMP];
     $event = new CommandEvent(ScriptEvents::POST_AUTOLOAD_DUMP, $this->composer, $this->io);
     $this->io->expects($this->at(0))->method('write')->with('<info>Generating PULI_FACTORY_CLASS constant</info>');
     $this->io->expects($this->at(1))->method('write')->with('<info>Registering Puli\\MyFactory with the class-map autoloader</info>');
     $this->puliRunner->expects($this->at(0))->method('run')->with("config 'factory.in.class' --parsed")->willReturn("Puli\\MyFactory\n");
     $this->puliRunner->expects($this->at(1))->method('run')->with("config 'factory.in.file' --parsed")->willReturn("My/Factory.php\n");
     $this->plugin->{$listener}($event);
     $this->assertFileExists($this->tempDir . '/the-vendor/autoload.php');
     require $this->tempDir . '/the-vendor/autoload.php';
     $this->assertTrue(defined('PULI_FACTORY_CLASS'));
     $this->assertSame('Puli\\MyFactory', PULI_FACTORY_CLASS);
 }