本文整理汇总了PHP中PHPUnit_Framework_TestCase::setExpectedException方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestCase::setExpectedException方法的具体用法?PHP PHPUnit_Framework_TestCase::setExpectedException怎么用?PHP PHPUnit_Framework_TestCase::setExpectedException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestCase
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestCase::setExpectedException方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notContainsValue
/**
* @test
*/
public function notContainsValue()
{
$collection = $this->getCollectionInstance(['fuu', 'bar']);
parent::assertFalse($collection->contains('baz'));
parent::setExpectedException(KeyIsNotDefinedException::class);
$collection->get('baz');
}
示例2: testUserCreateCommand_userCannotBeCreatedByLoggedInUser
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', 'asdasd@asdas.com', 'password');
$adapter->dispatchCommand($command);
}
示例3: testInstanceLimit
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();
}
示例4: testWebsiteScraper_aPageWithNoProductInfoThrowsAnException
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');
}
示例5: testUserDetailsQuery_exceptionThrownWhenNoInfoProvided
public function testUserDetailsQuery_exceptionThrownWhenNoInfoProvided()
{
$user = factory(App\Models\User::class, 1)->create();
$user->password = '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);
}
示例6: testUserUpdateCommand_invalidEmailThrowsException
public function testUserUpdateCommand_invalidEmailThrowsException()
{
$user = factory(App\Models\User::class)->create(['email' => 'temp@temp.com']);
$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' => 'temp@temp.com']);
$this->tester->dontSeeEventTriggered(\App\Events\UserUpdatedEvent::class);
}
示例7: test_error_state_mismatch_response
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);
}