當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ApplicationTester::run方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Tester\ApplicationTester::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP ApplicationTester::run方法的具體用法?PHP ApplicationTester::run怎麽用?PHP ApplicationTester::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Tester\ApplicationTester的用法示例。


在下文中一共展示了ApplicationTester::run方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: exec

 /**
  * 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();
 }
開發者ID:onedal88,項目名稱:deployer,代碼行數:15,代碼來源:RecipeTester.php

示例2: run

 /**
  * @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));
 }
開發者ID:scato,項目名稱:phpeg,代碼行數:13,代碼來源:ApplicationContext.php

示例3: test_CommandSkipsExisitingUsers_IfSkipExistingOptionUsed

 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);
 }
開發者ID:heiglandreas,項目名稱:plugin-LoginLdap,代碼行數:9,代碼來源:SynchronizeUsersTest.php

示例4: iRunPhpzoneWith

 /**
  * @When I run phpzone
  * @When I run phpzone with :command
  * @When I run phpzone with :command and :option
  */
 public function iRunPhpzoneWith($command = null, $option = null)
 {
     $input = array('--no-tty' => true);
     $input = array_merge($input, array($command));
     if ($option !== null) {
         $input = array_merge($input, array($option => true));
     }
     $this->tester->run($input);
 }
開發者ID:phpzone,項目名稱:docker,代碼行數:14,代碼來源:ApplicationContext.php

示例5: test_CommandResetsPassword_WhenUserIsLdapUserAndAlreadySynchronized

 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']);
 }
開發者ID:heiglandreas,項目名稱:plugin-LoginLdap,代碼行數:9,代碼來源:RegenerateTokenAuthTest.php

示例6: iRunCommand

 /**
  * @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();
 }
開發者ID:Hexmedia,項目名稱:Crontab,代碼行數:18,代碼來源:ApplicationContext.php

示例7: test_FixDuplicateLogActions_CorrectlyRemovesDuplicates_AndFixesReferencesInOtherTables

 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());
     }
 }
開發者ID:JoeHorn,項目名稱:piwik,代碼行數:14,代碼來源:FixDuplicateActionsTest.php

示例8: testUserCreationWithOptions

    public function testUserCreationWithOptions()
    {
        $kernel = $this->createKernel();
        $command = new CreateUserCommand();
        $application = new Application($kernel);
        $application->setAutoExit(false);
        $tester = new ApplicationTester($application);
        $username = 'test_username';
        $password = 'test_password';
        $email    = 'test_email@email.org';
        $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);
    }
開發者ID:naderman,項目名稱:UserBundle,代碼行數:29,代碼來源:CreateUserCommandTest.php

示例9: testUserActivation

 public function testUserActivation()
 {
     $kernel = $this->createKernel();
     $command = new ActivateUserCommand();
     $application = new Application($kernel);
     $application->setAutoExit(false);
     $tester = new ApplicationTester($application);
     $username = 'test_username';
     $password = 'test_password';
     $email = 'test_email@email.org';
     $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);
 }
開發者ID:KnpLabs,項目名稱:KnpUserBundle,代碼行數:26,代碼來源:ActivateUserCommandTest.php

示例10: testPromotion

    public function testPromotion()
    {
        $kernel = $this->createKernel();
        $command = new PromoteSuperAdminCommand();
        $application = new Application($kernel);
        $application->setAutoExit(false);
        $tester = new ApplicationTester($application);
        $username = 'test_username';
        $password = 'test_password';
        $email    = 'test_email@email.org';
        $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);
    }
開發者ID:naderman,項目名稱:UserBundle,代碼行數:30,代碼來源:PromoteSuperUserCommandTest.php

示例11: runCommand

 /**
  * 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;
 }
開發者ID:carbontwelve,項目名稱:azure-monitor,代碼行數:14,代碼來源:CommandTestBase.php

示例12: testRunWithConfigThrowExceptionIfExtensionClassDoesNotImplementsInterface

 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());
 }
開發者ID:carew,項目名稱:carew,代碼行數:7,代碼來源:CarewTest.php

示例13: iRunPhpspecAndAnswerWhenAskedIfIWantToGenerateTheCode

 /**
  * @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));
 }
開發者ID:ProgrammingPeter,項目名稱:nba-schedule-api,代碼行數:11,代碼來源:ApplicationContext.php

示例14: testBundleCommandsHaveRightContainer

 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'));
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:16,代碼來源:ApplicationTest.php

示例15: testExecute

 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());
 }
開發者ID:setbased,項目名稱:php-stratum,代碼行數:8,代碼來源:StratumApplicationTest.php


注:本文中的Symfony\Component\Console\Tester\ApplicationTester::run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。