/** * @test */ public function notContainsValue() { $collection = $this->getCollectionInstance(['fuu', 'bar']); parent::assertFalse($collection->contains('baz')); parent::setExpectedException(KeyIsNotDefinedException::class); $collection->get('baz'); }
public function testUserCreateCommand_userCannotBeCreatedByLoggedInUser() { $adapter = app('App\\Adapters\\MockAdapter'); $adapter->setAuthState(1, 1, false); \PHPUnit_Framework_TestCase::setExpectedException('App\\Exceptions\\AuthorisationException'); $command = new UserCreateCommand('slice-beans', '*****@*****.**', 'password'); $adapter->dispatchCommand($command); }
public function testInstanceLimit() { $object = Stub::construct('\\WPDemo\\Generator', array(), array('getConfig' => function () { $config = new \WPDemo\Config(); $config->limit = 0; return $config; })); \PHPUnit_Framework_TestCase::setExpectedException('\\Exception'); $object->instantiateSession(); }
public function testWebsiteScraper_aPageWithNoProductInfoThrowsAnException() { $mockDownloader = \Mockery::mock(WebsiteDownloader::class); $mockDownloader->shouldReceive('download')->once()->andReturn(file_get_contents(codecept_data_dir() . 'emptyPage.html')); $sampleProduct = new Product("Title", "Description", "0.01", "Big"); $mockPDPParser = \Mockery::mock(PDPParser::class); $mockPDPParser->shouldReceive('parseUrl')->times(0); \PHPUnit_Framework_TestCase::setExpectedException('Slice\\CliApp\\ScrapeException'); $pdpParser = new WebsiteScraper($mockPDPParser, $mockDownloader); $productResults = $pdpParser->getProductsForUrl('http://fakeUrl.com'); }
public function testUserDetailsQuery_exceptionThrownWhenNoInfoProvided() { $user = factory(App\Models\User::class, 1)->create(); $user->password = '******'; $user->save(); $adapter = app('App\\Adapters\\MockAdapter'); $adapter->setAuthState(null, null, false); \PHPUnit_Framework_TestCase::setExpectedException('App\\Exceptions\\ValidationException'); $command = new UserDetailsQuery(); $adapter->dispatchCommand($command); }
public function testUserUpdateCommand_invalidEmailThrowsException() { $user = factory(App\Models\User::class)->create(['email' => '*****@*****.**']); $adapter = app('App\\Adapters\\MockAdapter'); $adapter->setAuthState($user->id, $user->id, false); \PHPUnit_Framework_TestCase::setExpectedException('App\\Exceptions\\ValidationException'); $command = new UserUpdateCommand('asdfasdf'); $adapter->dispatchCommand($command); $this->tester->seeRecord('users', ['id' => $user->id, 'email' => '*****@*****.**']); $this->tester->dontSeeEventTriggered(\App\Events\UserUpdatedEvent::class); }
public function test_error_state_mismatch_response() { PHPUnit_Framework_TestCase::setExpectedException('\\Communique\\Interceptors\\JSON\\JSONParseException', 'Invalid or malformed JSON'); $response = new \Communique\RESTClientResponse(200, 'this is not json'); $this->JSON->response($response); }