コード例 #1
0
ファイル: CarewTest.php プロジェクト: carew/carew
 public function testRunWithConfigThrowExceptionIfExtensionClassDoesNotImplementsInterface()
 {
     $application = new ApplicationTester($this->carew);
     $statusCode = $application->run(array('command' => 'list', '--base-dir' => __DIR__ . '/Command/fixtures/config-exception-class-not-implements'));
     $this->assertSame(1, $statusCode);
     $this->assertContains('The class "stdClass" does not implements ExtensionInterface. See "config.yml".', $application->getDisplay());
 }
コード例 #2
0
    public function testUserCreationWithOptions()
    {
        $kernel = $this->createKernel();
        $command = new CreateUserCommand();
        $application = new Application($kernel);
        $application->setAutoExit(false);
        $tester = new ApplicationTester($application);
        $username = '******';
        $password = '******';
        $email    = '*****@*****.**';
        $tester->run(array(
            'command'  => $command->getFullName(),
            'username' => $username,
            'password' => $password,
            'email'    => $email,
            '--inactive' => true,
            '--super-admin' => true
        ), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));

        $userManager = $this->getService('fos_user.user_manager');
        $user = $userManager->findUserByUsername($username);

        $this->assertTrue($user instanceof User);
        $this->assertEquals($email, $user->getEmail());
        $this->assertFalse($user->isEnabled());
        $this->assertTrue($user->hasRole('ROLE_SUPERADMIN'));

        $userManager->deleteUser($user);
    }
コード例 #3
0
ファイル: RecipeTester.php プロジェクト: onedal88/deployer
 /**
  * Execute command with tester.
  *
  * @param string $command
  * @param array $args
  * @param array $options
  * @return string Display result.
  */
 protected function exec($command, $args = [], $options = [])
 {
     $this->tester->run(['command' => $command] + $args, $options);
     // Clear realpath cache.
     clearstatcache(self::$deployPath);
     return $this->tester->getDisplay();
 }
コード例 #4
0
 /**
  * Using the cli application itself, execute a command that already exists
  *
  * @param string $command
  * @param array $arguments
  * @return ApplicationTester
  */
 protected function runCommand($command, array $arguments = [])
 {
     $applicationTester = new ApplicationTester($this->getCli());
     $arguments = array_merge(['command' => $command], $arguments);
     $applicationTester->run($arguments);
     return $applicationTester;
 }
コード例 #5
0
 public function testUserActivation()
 {
     $kernel = $this->createKernel();
     $command = new ActivateUserCommand();
     $application = new Application($kernel);
     $application->setAutoExit(false);
     $tester = new ApplicationTester($application);
     $username = '******';
     $password = '******';
     $email = '*****@*****.**';
     $userManager = $this->getService('fos_user.user_manager');
     $user = $userManager->createUser();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled(false);
     $userManager->updateUser($user);
     $this->assertFalse($user->isEnabled());
     $tester->run(array('command' => $command->getFullName(), 'username' => $username), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));
     $this->getService('doctrine.orm.default_entity_manager')->clear();
     $userManager = $this->getService('fos_user.user_manager');
     $user = $userManager->findUserByUsername($username);
     $this->assertTrue($user instanceof User);
     $this->assertTrue($user->isEnabled());
     $userManager->updateUser($user);
 }
コード例 #6
0
    public function testPromotion()
    {
        $kernel = $this->createKernel();
        $command = new PromoteSuperAdminCommand();
        $application = new Application($kernel);
        $application->setAutoExit(false);
        $tester = new ApplicationTester($application);
        $username = '******';
        $password = '******';
        $email    = '*****@*****.**';
        $userManager = $kernel->getContainer()->get('fos_user.user_manager');
        $user = $userManager->createUser();
        $user->setUsername($username);
        $user->setEmail($email);
        $user->setPlainPassword($password);
        $userManager->updateUser($user);
        $this->assertFalse($user->hasRole('ROLE_SUPERADMIN'));
        $tester->run(array(
            'command'  => $command->getFullName(),
            'username' => $username,
        ), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));

        $userManager = $this->getService('fos_user.user_manager');
        $user = $userManager->findUserByUsername($username);

        $this->assertTrue($user instanceof User);
        $this->assertTrue($user->hasRole('ROLE_SUPERADMIN'));

        $userManager->deleteUser($user);
    }
コード例 #7
0
 /**
  * @test
  */
 public function shouldExecuteSuccessfully()
 {
     $app = new Application($this->srcDir, 'PHP Test Reporter', '1.0.0');
     $app->setAutoExit(false);
     $tester = new ApplicationTester($app);
     $status = $tester->run(['--stdout' => true]);
     $this->assertEquals(0, $status);
 }
コード例 #8
0
 public function testRun()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $applicationTester = new ApplicationTester($application);
     $applicationTester->run([]);
     $this->assertContains('WebHelper version 0.2', $applicationTester->getDisplay([]));
 }
コード例 #9
0
 public function testExecute()
 {
     $application = new Stratum();
     $application->setAutoExit(false);
     $tester = new ApplicationTester($application);
     $tester->run(['config file' => 'test/MySql/etc/stratum.cfg']);
     $this->assertSame(0, $tester->getStatusCode(), $tester->getDisplay());
 }
コード例 #10
0
ファイル: ApplicationContext.php プロジェクト: scato/phpeg
 /**
  * @param string $command
  *
  * @return integer
  */
 private function run($command)
 {
     $application = $this->createApplication();
     $application->setAutoExit(false);
     $this->applicationTester = new ApplicationTester($application);
     $this->outputFile = tempnam('.', 'phpeg');
     return $this->applicationTester->run(array('command' => $command, 'input-file' => $this->inputFile, 'output-file' => $this->outputFile));
 }
コード例 #11
0
ファイル: ApplicationContext.php プロジェクト: phpzone/shell
 /**
  * @Then I should see:
  */
 public function iShouldSee(PyStringNode $content)
 {
     $displayArray = explode("\n", $this->tester->getDisplay());
     array_walk($displayArray, function (&$line) {
         $line = rtrim($line);
     });
     expect($displayArray)->shouldBeLike($content->getStrings());
 }
コード例 #12
0
 public function testLoadedCommandRuns()
 {
     $this->markTestSkipped('The ' . __CLASS__ . ' Symfony ... Console App ... so difficult to extend and test :[');
     $consoleApp = new Console();
     $consoleApp->setAutoExit(false);
     $tester = new ApplicationTester($consoleApp);
     $tester->run(array('command' => 'test:command', 'name' => 'Skip', '--skip-app-path' => './tests/fixtures/app'));
     $this->assertContains('Nice name you got there, Skip.', $tester->getDisplay());
 }
コード例 #13
0
ファイル: ApplicationTest.php プロジェクト: ASP96/imbo
 /**
  * @covers ImboCli\Application::__construct
  */
 public function testAddsCommands()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $applicationTester = new ApplicationTester($application);
     $applicationTester->run(array('command' => 'list'));
     $output = $applicationTester->getDisplay();
     $this->assertContains('generate-private-key', $output);
 }
コード例 #14
0
ファイル: ApplicationTest.php プロジェクト: insulin/cli
 /**
  * Confirm that all the core commands with bootstrap level
  * `BOOT_SUGAR_ROOT` will be available by default.
  */
 public function testDebugOutput()
 {
     $kernel = $this->getKernel(Kernel::BOOT_INSULIN, null, true);
     $insulin = new Application($kernel);
     $insulin->setAutoExit(false);
     $insulinTester = new ApplicationTester($insulin);
     $insulinTester->run(array('command' => 'list'));
     $this->assertRegExp('/Memory usage: (.*)MB \\(peak: (.*)MB\\), time: (.*)s/', $insulinTester->getDisplay());
 }
コード例 #15
0
 public function test_CommandSkipsExisitingUsers_IfSkipExistingOptionUsed()
 {
     $this->addPreexistingSuperUser();
     $result = $this->applicationTester->run(array('command' => 'loginldap:synchronize-users', '--login' => array('ironman', 'captainamerica'), '--skip-existing' => true, '-v' => true));
     $this->assertEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
     $this->assertContains("Skipping 'captainamerica', already exists in Piwik...", $this->applicationTester->getDisplay());
     $users = $this->getLdapUserLogins();
     $this->assertEquals(array('ironman'), $users);
 }
コード例 #16
0
 public function test_CommandResetsPassword_WhenUserIsLdapUserAndAlreadySynchronized()
 {
     Config::getInstance()->LoginLdap['enable_random_token_auth_generation'] = 1;
     $result = $this->applicationTester->run(array('command' => 'loginldap:generate-token-auth', 'login' => self::PREEXISTING_LDAP_USER));
     $this->assertEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
     $user = $this->getUser(self::PREEXISTING_LDAP_USER);
     $this->assertNotEquals(self::PREEXISTING_PASSWORD, $user['password']);
     $this->assertNotEquals(self::PREEXISTING_TOKEN_AUTH, $user['token_auth']);
 }
コード例 #17
0
 public function testInvalidConnectionCausesError()
 {
     $kernel = $this->createKernel('badconn.yml');
     $console = new Application($kernel);
     $console->setAutoExit(false);
     $tester = new ApplicationTester($console);
     $this->assertGreaterThan(0, $tester->run(['pheanstalk:stats', 'tube' => ['default']]));
     $this->assertContains('Pheanstalk\\Exception', $tester->getDisplay());
 }
コード例 #18
0
 /**
  * @param string       $command
  * @param string       $file
  * @param PyStringNode $options
  *
  * @When /^I run (?P<command>[a-zA-Z0-9\.\:]*) command with file \"(?P<file>[^\"]*)\"$/
  * @When /^I run (?P<command>[a-zA-Z0-9\.\:]*) command with file \"(?P<file>[^\"]*)\" and options:$/
  */
 public function iRunCommand($command, $file = null, PyStringNode $options = null)
 {
     $arguments = array('command' => $command, 'name' => 'Test');
     $arguments['configuration-file'] = __DIR__ . "/../../" . $file;
     $options = $this->parseOptions($options);
     $arguments += $options;
     $runOptions = array('interactive' => false, 'decorated' => false);
     $this->lastExitCode = $this->tester->run($arguments, $runOptions);
     $this->lastDisplay = $this->tester->getDisplay();
 }
コード例 #19
0
 public function testExecute()
 {
     self::bootKernel();
     $application = new Application(static::$kernel);
     $application->setCatchExceptions(false);
     $application->setAutoExit(false);
     $tester = new ApplicationTester($application);
     $tester->run(['command' => 'api:swagger:export']);
     $this->assertJson($tester->getDisplay());
 }
コード例 #20
0
ファイル: consoleTest.php プロジェクト: havvg/Sismo
 public function testVerboseBuildForProject()
 {
     $project = $this->getMockBuilder('Sismo\\Project')->disableOriginalConstructor()->getMock();
     $this->app['sismo']->expects($this->once())->method('hasProject')->will($this->returnValue(true));
     $this->app['sismo']->expects($this->once())->method('getProject')->will($this->returnValue($project));
     $this->app['sismo']->expects($this->once())->method('build');
     $tester = new ApplicationTester($this->console);
     $this->assertEquals(0, $tester->run(array('command' => 'build', 'slug' => 'Twig', '--verbose' => true)));
     $this->assertEquals('Building Project "" (into "d41d8c")', trim($tester->getDisplay()));
 }
コード例 #21
0
 public function testTestBeforeAndAfterAncestryCommand()
 {
     $application = new Application($this->container);
     $application->setAutoExit(false);
     $applicationTester = new ApplicationTester($application);
     $applicationTester->run(array("command" => "testAncestry1", "--verbose" => 3));
     $output = $applicationTester->getDisplay();
     $this->assertRegExp("/Skip a before task testAncestry1 to prevent infinite loop. Because of existing it in ancestry tasks./", $output);
     //        echo $output;
 }
コード例 #22
0
ファイル: ApplicationTest.php プロジェクト: graste/environaut
 public function testProfileRun()
 {
     $application = new Application('1337');
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('--profile' => true), array('decorated' => false));
     $output = $tester->getDisplay(true);
     $this->assertContains('Environaut version 1337', $output);
     $this->assertContains('Memory usage: ', $output);
 }
コード例 #23
0
ファイル: FizzBuzzTest.php プロジェクト: hnw/fizzbuzz
 public function testLimit()
 {
     $app = new Application();
     $app->add(new FizzBuzzCommand());
     $app->setAutoExit(false);
     // For testing
     $tester = new ApplicationTester($app);
     $tester->run(array('--limit' => '15'), array('decorated' => false));
     $this->assertContains("14", $tester->getDisplay(true));
     $this->assertContains("Fizz Buzz", $tester->getDisplay(true));
     $this->assertNotContains("16", $tester->getDisplay(true));
 }
コード例 #24
0
 /**
  * @dataProvider provider
  */
 public function testRun($command, $result)
 {
     $app = new \Phinx\Console\PhinxApplication('testing');
     $app->setAutoExit(false);
     // Set autoExit to false when testing
     $app->setCatchExceptions(false);
     $appTester = new ApplicationTester($app);
     $appTester->run(array('command' => $command));
     $stream = $appTester->getOutput()->getStream();
     rewind($stream);
     $this->assertRegExp($result, stream_get_contents($stream));
 }
コード例 #25
0
ファイル: ApplicationTest.php プロジェクト: maartenstaa/phpta
 /**
  * @covers ::getCommandName
  * @covers ::getDefinition
  */
 public function testCanRunCommandWithoutSpecifyingName()
 {
     // Replace command by a mock.
     $mock = $this->getMockBuilder('MaartenStaa\\PHPTA\\CLI\\Command')->setMethods(array('execute'))->getMock();
     $mock->expects($this->once())->method('execute');
     $application = new Application();
     $application->setAutoExit(false);
     $application->add($mock);
     $tester = new ApplicationTester($application);
     $tester->run(array());
     $this->assertEquals('', $tester->getDisplay());
 }
コード例 #26
0
ファイル: ApplicationTest.php プロジェクト: straiway/fmt
 /**
  * @test
  */
 public function shouldExecuteCoverallsV1JobsCommand()
 {
     $this->makeProjectDir(null, $this->logsDir);
     $this->dumpCloverXml();
     $app = new Application($this->rootDir, 'Coveralls API client for PHP', '1.0.0');
     $app->setAutoExit(false);
     // avoid to call exit() in Application
     // run
     $_SERVER['TRAVIS'] = true;
     $_SERVER['TRAVIS_JOB_ID'] = 'application_test';
     $tester = new ApplicationTester($app);
     $actual = $tester->run(array('--dry-run' => true, '--config' => 'coveralls.yml'));
     $this->assertEquals(0, $actual);
 }
コード例 #27
0
 public function test_FixDuplicateLogActions_CorrectlyRemovesDuplicates_AndFixesReferencesInOtherTables()
 {
     $result = $this->applicationTester->run(array('command' => 'core:fix-duplicate-log-actions', '--invalidate-archives' => 0, '-vvv' => false));
     $this->assertEquals(0, $result, "Command failed: " . $this->applicationTester->getDisplay());
     $this->assertDuplicateActionsRemovedFromLogActionTable();
     $this->assertDuplicatesFixedInLogLinkVisitActionTable();
     $this->assertDuplicatesFixedInLogConversionTable();
     $this->assertDuplicatesFixedInLogConversionItemTable();
     $this->assertContains("Found and deleted 7 duplicate action entries", $this->applicationTester->getDisplay());
     $expectedAffectedArchives = array(array('idsite' => '1', 'server_time' => '2012-01-01'), array('idsite' => '2', 'server_time' => '2013-01-01'), array('idsite' => '1', 'server_time' => '2012-02-01'), array('idsite' => '2', 'server_time' => '2012-01-09'), array('idsite' => '2', 'server_time' => '2012-03-01'));
     foreach ($expectedAffectedArchives as $archive) {
         $this->assertContains("[ idSite = {$archive['idsite']}, date = {$archive['server_time']} ]", $this->applicationTester->getDisplay());
     }
 }
コード例 #28
0
 /**
  * @When I run phpspec and answer :answer when asked if I want to generate the code
  * @When I run phpspec with the option :option and (I) answer :answer when asked if I want to generate the code
  */
 public function iRunPhpspecAndAnswerWhenAskedIfIWantToGenerateTheCode($answer, $option = null)
 {
     $arguments = array('command' => 'run');
     $this->addOptionToArguments($option, $arguments);
     $this->prompter->setAnswer($answer == 'y');
     $this->lastExitCode = $this->tester->run($arguments, array('interactive' => true));
 }
コード例 #29
0
ファイル: ApplicationTest.php プロジェクト: rabellamy/flo
 /**
  * Test Successful doRun.
  */
 function testExistingHubApplication()
 {
     // Create a Mock Process Object.
     $process = $this->getMockBuilder('Symfony\\Component\\Process\\Process')->disableOriginalConstructor()->getMock();
     // Make sure the isSuccessful method return FALSE so flo throws an exception.
     $process->method('isSuccessful')->willReturn(TRUE);
     $app = new Console\Application();
     // Set autoExit to false when testing & do not let it catch exceptions.
     $app->setAutoExit(FALSE);
     // Overwrite Symfony\Component\Process\Process with our mock Process.
     $app->setProcess($process);
     // Run a command and wait for the exception.
     $appTester = new ApplicationTester($app);
     $appTester->run(array('command' => 'help'));
     $this->assertEquals(0, $appTester->getStatusCode());
 }
コード例 #30
0
 public function testBundleCommandsHaveRightContainer()
 {
     $command = $this->getMockForAbstractClass('Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand', array('foo'), '', true, true, true, array('setContainer'));
     $command->setCode(function () {
     });
     $command->expects($this->exactly(2))->method('setContainer');
     $application = new Application($this->getKernel(array()));
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add($command);
     $tester = new ApplicationTester($application);
     // set container is called here
     $tester->run(array('command' => 'foo'));
     // as the container might have change between two runs, setContainer must called again
     $tester->run(array('command' => 'foo'));
 }