Created
March 24, 2012 09:58
-
-
Save yuya-takeyama/2180749 to your computer and use it in GitHub Desktop.
What's Test Spy?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Example\Application\Tests; | |
use \Example\Application; | |
use \SymfonyX\Component\Console\Output\SpyOutput; | |
class ApplicationTest extends \PHPUnit_Framework_TestCase | |
{ | |
private $app; | |
private $spy; | |
public function setUp() | |
{ | |
$this->spy = new SpyOutput; | |
$this->app = new Application($this->spy); | |
} | |
public function testAppOutputsCorrectly() | |
{ | |
$this->app->run(); | |
$this->assertEquals('Hello, World!' . PHP_EOL, $this->spy->getMessage()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ExampleApp\Tests; | |
use \ExampleApp\Progress; | |
use \SymfonyX\Component\Console\Output\SpyOutput; | |
class ProgressTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function test_progress_works_correctly() | |
{ | |
$expected = <<< __EOF__ | |
[ 0%] 0/100 | |
[ 10%] 10/100 | |
[ 20%] 20/100 | |
[ 30%] 30/100 | |
[ 40%] 40/100 | |
[ 50%] 50/100 | |
[ 60%] 60/100 | |
[ 70%] 70/100 | |
[ 80%] 80/100 | |
[ 90%] 90/100 | |
[100%] 100/100 | |
__EOF__; | |
$spy = new SpyOutput; | |
$progress = new Progress(100, $spy); | |
for ($i = 0; $i < 100; $i++) { | |
$progress->setCurrentPosition($i); | |
} | |
$this->assertEquals($expected, $spy->getMessage()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ExampleApp\Command; | |
use \ExampleApp\Progress; | |
use \Symfony\Component\Console\Command\Command, | |
\Symfony\Component\Console\Input\InputInterface, | |
\Symfony\Component\Console\Output\OutputInterface; | |
class ExecuteCommand extends Command | |
{ | |
public function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$records = findRecords(); | |
$progress = new Progress(count($records), $output); | |
foreach ($records as $i => $record) { | |
$progress->setCurrentPosition($i); | |
} | |
} | |
} |
The issue of application safety is very relevant for me now. I really want to install a spy app on my wife's phone, I studied everything in detail on this source realspyapps.com/review/pctattletale/ and I think that there should be no problems with installation, but I'm very afraid that she will be able to notice the appearance of a spy on her phone. Anyone faced a similar situation? Do spy apps really work discreetly and safely?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, thanks!