/** * @test */ public function canBatchAssertGivenResponse() { $collection = new CommandCollection(); $collection->add(new Command('sudo apt-get update')); $batch = new Batch(); $batch->addCommandCollection($collection); $batch->addAssertion(new Regex('/Done$/')); $response = ['Get:18 http://archive.ubuntu.com trusty-security/main amd64 Packages [388 kB]', 'Get:19 http://archive.ubuntu.com trusty-security/restricted amd64 Packages [14.8 kB]', 'Get:20 http://archive.ubuntu.com trusty-security/universe amd64 Packages [143 kB]', 'Get:21 http://archive.ubuntu.com trusty-security/main i386 Packages [370 kB]', 'Get:22 http://archive.ubuntu.com trusty-security/restricted i386 Packages [14.8 kB]', 'Get:23 http://archive.ubuntu.com trusty-security/universe i386 Packages [143 kB]', 'Hit http://downloads-distro.mongodb.org dist/10gen i386 Packages', 'Hit http://linux.dropbox.com precise/main amd64 Packages', 'Get:24 http://toolbelt.heroku.com ./ Release [1609 B]', 'Hit http://linux.dropbox.com precise/main i386 Packages', 'Get:25 http://toolbelt.heroku.com ./ Packages [1061 B]', 'Fetched 4010 kB in 3s (1004 kb/s)', 'Reading package lists... Done']; $batch->setProcessResponse(implode(PHP_EOL, $response)); $this->assertTrue($batch->isValid(), 'Batch should have been validated on new response data given'); $batch->addAssertion(new Regex('/ubuntu\\.com/')); $batch->addAssertion(new Assertion('Failed')); $this->assertTrue($batch->isValid(), 'Batch should still be valid after new assertions are added'); $batch->validate(); $this->assertFalse($batch->isValid(), 'Batch should not be invalid as validation is ran again'); }