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


PHP Tester\ApplicationTester類代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: shouldExecuteSuccessfully

 /**
  * @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);
 }
開發者ID:codeclimate,項目名稱:php-test-reporter,代碼行數:11,代碼來源:ApplicationTest.php

示例7: testRun

 public function testRun()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $applicationTester = new ApplicationTester($application);
     $applicationTester->run([]);
     $this->assertContains('WebHelper version 0.2', $applicationTester->getDisplay([]));
 }
開發者ID:jamesrezo,項目名稱:webhelper,代碼行數:8,代碼來源:ApplicationTest.php

示例8: 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

示例9: 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

示例10: testLoadedCommandRuns

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

示例11: testAddsCommands

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

示例12: testDebugOutput

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

示例13: testInvalidConnectionCausesError

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

示例14: testExecute

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

示例15: testVerboseBuildForProject

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


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