예제 #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);
 }
 private function verifyPuliVersion()
 {
     $versionString = $this->puliRunner->run('-V');
     if (!preg_match('~^Puli version (\\S+)$~', $versionString, $matches)) {
         throw new RuntimeException(sprintf('Could not determine Puli version. "puli -V" returned: %s', $versionString));
     }
     // the development build of the plugin is always considered compatible
     // with the development build of the CLI
     // Split strings to prevent replacement during release
     if ('@package_' . 'version@' === self::VERSION && '@package_' . 'version@' === $matches[1]) {
         return;
     }
     if (version_compare($matches[1], self::MIN_CLI_VERSION, '<')) {
         throw new RuntimeException(sprintf('Found an unsupported version of the Puli CLI: %s. Please ' . 'upgrade to version %s or higher. You can also install the ' . 'puli/cli dependency at version %s in your project.', $matches[1], self::MIN_CLI_VERSION, self::MIN_CLI_VERSION));
     }
     if (version_compare($matches[1], self::MAX_CLI_VERSION, '>')) {
         throw new RuntimeException(sprintf('Found an unsupported version of the Puli CLI: %s. Please ' . 'downgrade to a lower version than %s. You can also install ' . 'the puli/cli dependency in your project.', $matches[1], self::MAX_CLI_VERSION));
     }
 }
예제 #4
0
 private function renamePackage($name, $newName)
 {
     $this->puliRunner->run('package --rename %old_name% %new_name%', array('old_name' => $name, 'new_name' => $newName));
 }
예제 #5
0
 private function renamePackage($name, $newName)
 {
     $this->puliRunner->run(sprintf('package --rename %s %s', escapeshellarg($name), escapeshellarg($newName)));
 }