Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use EventuallyConsistentTestTrait for a test
Browse files Browse the repository at this point in the history
Takashi Matsuo committed Oct 11, 2016
1 parent 2e8eb23 commit a6d4671
Showing 3 changed files with 332 additions and 43 deletions.
3 changes: 2 additions & 1 deletion logging/api/composer.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
"symfony/console": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
"phpunit/phpunit": "~4.8",
"google/cloud-tools": "<2.0"
},
"autoload": {
"psr-4": { "Google\\Cloud\\Samples\\Logging\\": "src" },
353 changes: 317 additions & 36 deletions logging/api/composer.lock
19 changes: 13 additions & 6 deletions logging/api/test/ListEntriesCommandTest.php
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@

use Google\Cloud\Samples\Logging\ListEntriesCommand;
use Google\Cloud\Samples\Logging\WriteCommand;
use Google\Cloud\TestUtils\EventuallyConsistentTestTrait;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;

@@ -27,6 +28,8 @@
*/
class ListEntriesCommandTest extends \PHPUnit_Framework_TestCase
{
use EventuallyConsistentTestTrait;

/* @var $hasCredentials boolean */
protected static $hasCredentials;
/* @var $projectId mixed|string */
@@ -59,18 +62,22 @@ public function setUp()
],
['interactive' => false]
);
sleep(2);
}

public function testListEntries()
{
$application = new Application();
$application->add(new ListEntriesCommand());
$commandTester = new CommandTester($application->get('list-entries'));
$commandTester->execute(
['--project' => $this->projectId, '--logger' => 'my_test_logger'],
['interactive' => false]
);
$this->expectOutputRegex('/: Test Message/');
$this->runEventuallyConsistentTest(function() use ($commandTester) {
$commandTester->execute(
[
'--project' => $this->projectId,
'--logger' => 'my_test_logger'
],
['interactive' => false]
);
$this->expectOutputRegex('/: Test Message/');
});
}
}

0 comments on commit a6d4671

Please sign in to comment.