public function testChildCallsOnShutdown() { $expected = 'onShutdown called'; $this->command->setShutdownOutput($expected); $this->setupStartFunctions(null); $pcntl_signal = $this->getFunctionMock('\\Phlib\\ConsoleProcess\\Command', 'pcntl_signal'); $pcntl_signal->expects($this->any())->will($this->returnValue(true)); $this->tester->execute(['action' => 'start', '-p' => '/path/to/my.pid', '-d' => true]); $this->assertContains("{$expected}\n", $this->tester->getDisplay()); }
public function testAsXml() { $command = new \TestCommand(); $command->setApplication(new Application()); $tester = new CommandTester($command); $tester->execute(array('command' => $command->getName())); $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command'); }
public function testSetCodeWithNonClosureCallable() { $command = new \TestCommand(); $ret = $command->setCode(array($this, 'callableMethodCommand')); $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute(array()); $this->assertEquals('interact called' . PHP_EOL . 'from the code...' . PHP_EOL, $tester->getDisplay()); }
public function testLegacyAsXml() { $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $command = new \TestCommand(); $command->setApplication(new Application()); $tester = new CommandTester($command); $tester->execute(array('command' => $command->getName())); $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command'); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid callable provided to Command::setCode. */ public function testSetCodeWithNonCallable() { $command = new \TestCommand(); $command->setCode(array($this, 'nonExistentMethod')); }
$t->is($tester->execute(array(), array('interactive' => false)), "execute called\n", '->run() does not call the interact() method if the input is not interactive'); $command = new Command('foo'); try { $command->run(new StringInput(''), new NullOutput()); $t->fail('->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided'); } catch (\LogicException $e) { $t->pass('->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided'); } // ->setCode() $t->diag('->setCode()'); $command = new TestCommand(); $command->setApplication($application); $ret = $command->setCode(function (InputInterface $input, OutputInterface $output) { $output->writeln('from the code...'); }); $t->is($ret, $command, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute(array()); $t->is($tester->getDisplay(), "interact called\nfrom the code...\n"); // ->asText() $t->diag('->asText()'); $t->is($command->asText(), file_get_contents($fixtures.'/command_astext.txt'), '->asText() returns a text representation of the command'); // ->asXml()
public function testBaseCommandClassIsCalled() { $this->assertEquals($this->commandName, $this->command->getName()); }
public function testReportCommand() { global $l_id, $l_login, $l_name, $l_firstname, $l_domain_name; $cmd = new TestCommand(); $cmd->doIt(); $mailData = Stato_StaticTransport::getMailQ(); $this->assertEquals('Rapport d\'exploitation : Les utilisateurs qui ne sont pas dans global.virt',$mailData[0]['subject']); $this->assertEquals("domainezz.com Admin <*****@*****.**>", $mailData[0]['to']); $this->assertContains("Rapport d'exploitation du traitement \"Les utilisateurs qui ne sont pas dans global.virt\" :\n" ."\n" ."$l_id\t$l_login\t$l_name\t$l_firstname\t$l_domain_name\t\n" ."2\tadmin1\tAdmin\tdomainezz.com\tzz.com\t\n" ."3\tuser1\tDoe\tJohn\tzz.com\t\n" ."4\tediteur1\tDoe\tJane\tzz.com\t\n" ."6\tadmin2\tAdmin Lastname\tFirstname\tzz.com\t\n" ,$mailData[0]['content']); }
public function handleTestCommand(TestCommand $command) { $command->setInvoked(true); }
public function testAsXml() { $command = new \TestCommand(); $command->setApplication(new Application()); $tester = new CommandTester($command); $tester->execute(array()); $this->assertEquals($command->asXml(), file_get_contents(self::$fixturesPath . '/command_asxml.txt'), '->asXml() returns an XML representation of the command'); }