本文整理汇总了PHP中Monolog\Handler\TestHandler::hasWarning方法的典型用法代码示例。如果您正苦于以下问题:PHP TestHandler::hasWarning方法的具体用法?PHP TestHandler::hasWarning怎么用?PHP TestHandler::hasWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Handler\TestHandler
的用法示例。
在下文中一共展示了TestHandler::hasWarning方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testImgurFail
public function testImgurFail()
{
$imgurClient = $this->getMockBuilder('Imgur\\Client')->disableOriginalConstructor()->getMock();
$imgurClient->expects($this->any())->method('api')->will($this->throwException(new \Guzzle\Http\Exception\RequestException()));
$imgur = new Imgur($imgurClient);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$imgur->setLogger($logger);
$imgur->match('http://imgur.com/gallery/IoKwI7E');
$this->assertEmpty($imgur->getContent());
$this->assertTrue($logHandler->hasWarning('Imgur extract failed for: IoKwI7E'), 'Warning message matched');
}
示例2: testContentBadResponse
public function testContentBadResponse()
{
$twitterOAuth = $this->getMockBuilder('TwitterOAuth\\TwitterOAuth')->disableOriginalConstructor()->getMock();
$twitterOAuth->expects($this->once())->method('get')->will($this->throwException(new TwitterException()));
$twitter = new Twitter($twitterOAuth);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$twitter->setLogger($logger);
$twitter->match('https://twitter.com/DoerteDev/statuses/506522223860277248');
$this->assertEmpty($twitter->getContent());
$this->assertTrue($logHandler->hasWarning('Twitter extract failed for: 506522223860277248'), 'Warning message matched');
}
示例3: testContentWithException
public function testContentWithException()
{
$client = new Client();
$mock = new Mock([new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$camplus = new Camplus();
$camplus->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$camplus->setLogger($logger);
$camplus->match('http://campl.us/rL9Q');
// this one will catch an exception
$this->assertEmpty($camplus->getContent());
$this->assertTrue($logHandler->hasWarning('Camplus extract failed for: rL9Q'), 'Warning message matched');
}
示例4: testContentWithException
public function testContentWithException()
{
$client = new Client();
$mock = new Mock([new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$deviantart = new Deviantart();
$deviantart->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$deviantart->setLogger($logger);
$deviantart->match('http://mibreit.deviantart.com/art/A-Piece-of-Heaven-357105002');
// this one will catch an exception
$this->assertEmpty($deviantart->getContent());
$this->assertTrue($logHandler->hasWarning('Deviantart extract failed for: http://mibreit.deviantart.com/art/A-Piece-of-Heaven-357105002'), 'Warning message matched');
}
示例5: testPhotoSet
public function testPhotoSet()
{
$client = new Client();
$mock = new Mock([new Response(200, [], Stream::factory(json_encode(array('stat' => 'ok', 'photoset' => array('photo' => array(array('title' => 'Super title', 'url_l' => 'https://0.0.0.0/medium.jpg'), array('title' => 'Ugly title', 'url_o' => 'https://0.0.0.0/large.jpg'))))))), new Response(200, [], Stream::factory('')), new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$flickr = new Flickr('apikey');
$flickr->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$flickr->setLogger($logger);
// first test fail because we didn't match an url, so FlickrId isn't defined
$this->assertEmpty($flickr->getContent());
$flickr->match('https://www.flickr.com/photos/europeanspaceagency/sets/72157638315605535/');
// consecutive calls
$this->assertContains('<div><p>Super title</p><img src="https://0.0.0.0/medium.jpg" /></div>', $flickr->getContent());
// this one will got an empty array
$this->assertEmpty($flickr->getContent());
// this one will catch an exception
$this->assertEmpty($flickr->getContent());
$this->assertTrue($logHandler->hasWarning('Flickr extract failed for: 72157638315605535'), 'Warning message matched');
}
示例6: testContent
public function testContent()
{
$client = new Client();
$mock = new Mock([new Response(200, [], Stream::factory(json_encode(array('video' => array('title' => 'my title', 'thumbnail_url' => 'http://0.0.0.0/img.jpg', 'embed_url' => 'http://0.0.0.0/embed'))))), new Response(200, [], Stream::factory('')), new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$vidme = new Vidme();
$vidme->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$vidme->setLogger($logger);
// first test fail because we didn't match an url, so VidmeId isn't defined
$this->assertEmpty($vidme->getContent());
$vidme->match('https://vid.me/WaJr');
// consecutive calls
$this->assertEquals('<div><h2>my title</h2><p><img src="http://0.0.0.0/img.jpg"></p><iframe src="http://0.0.0.0/embed"></iframe></div>', $vidme->getContent());
// this one will got an empty array
$this->assertEmpty($vidme->getContent());
// this one will catch an exception
$this->assertEmpty($vidme->getContent());
$this->assertTrue($logHandler->hasWarning('Vidme extract failed for: https://vid.me/WaJr'), 'Warning message matched');
}
示例7: testContent
public function testContent()
{
$client = new Client();
$mock = new Mock([new Response(200, [], Stream::factory(json_encode(array('title' => 'my title', 'description' => 'my description', 'thumbnail_url' => 'http://0.0.0.0/img.jpg', 'html' => '<iframe/>')))), new Response(200, [], Stream::factory('')), new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$soundCloud = new Soundcloud();
$soundCloud->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$soundCloud->setLogger($logger);
// first test fail because we didn't match an url, so SoundcloudUrl isn't defined
$this->assertEmpty($soundCloud->getContent());
$soundCloud->match('https://soundcloud.com/birdfeeder/jurassic-park-theme-1000-slower');
// consecutive calls
$this->assertEquals('<div><h2>my title</h2><p>my description</p><p><img src="http://0.0.0.0/img.jpg"></p><iframe/></div>', $soundCloud->getContent());
// this one will got an empty array
$this->assertEmpty($soundCloud->getContent());
// this one will catch an exception
$this->assertEmpty($soundCloud->getContent());
$this->assertTrue($logHandler->hasWarning('Soundcloud extract failed for: https://soundcloud.com/birdfeeder/jurassic-park-theme-1000-slower'), 'Warning message matched');
}
示例8: testContent
public function testContent()
{
$client = new Client();
$mock = new Mock([new Response(200, [], Stream::factory(json_encode(array('title' => 'my title', 'thumbnail_url' => 'http://0.0.0.0/img.jpg', 'html' => '<iframe/>')))), new Response(200, [], Stream::factory('')), new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$dailymotion = new Dailymotion();
$dailymotion->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$dailymotion->setLogger($logger);
// first test fail because we didn't match an url, so DailymotionUrl isn't defined
$this->assertEmpty($dailymotion->getContent());
$dailymotion->match('https://www.dailymotion.com/video/xockol_planete-des-hommes-partie-1-2_travel');
// consecutive calls
$this->assertEquals('<div><h2>my title</h2><p><img src="http://0.0.0.0/img.jpg"></p><iframe/></div>', $dailymotion->getContent());
// this one will got an empty array
$this->assertEmpty($dailymotion->getContent());
// this one will catch an exception
$this->assertEmpty($dailymotion->getContent());
$this->assertTrue($logHandler->hasWarning('Dailymotion extract failed for: https://www.dailymotion.com/video/xockol_planete-des-hommes-partie-1-2_travel'), 'Warning message matched');
}
示例9: testContent
public function testContent()
{
$client = new Client();
$mock = new Mock([new Response(200, [], Stream::factory(json_encode(array('gfyItem' => array('title' => 'my title', 'gifUrl' => 'http://0.0.0.0/img.gif'))))), new Response(200, [], Stream::factory('')), new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$gfycat = new Gfycat();
$gfycat->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$gfycat->setLogger($logger);
// first test fail because we didn't match an url, so GfycatId isn't defined
$this->assertEmpty($gfycat->getContent());
$gfycat->match('http://gfycat.com/SingleUntriedBudgie');
// consecutive calls
$this->assertEquals('<div><h2>my title</h2><p><img src="http://0.0.0.0/img.gif"></p></div>', $gfycat->getContent());
// this one will got an empty array
$this->assertEmpty($gfycat->getContent());
// this one will catch an exception
$this->assertEmpty($gfycat->getContent());
$this->assertTrue($logHandler->hasWarning('Gfycat extract failed for: SingleUntriedBudgie'), 'Warning message matched');
}
示例10: testContent
public function testContent()
{
$client = new Client();
$mock = new Mock([new Response(200, ['X-Tumblr-User' => 'test']), new Response(200, ['X-Tumblr-User' => 'test'], Stream::factory(json_encode(array('response' => array('posts' => array(array('body' => '<div>content</div>'))))))), new Response(200, ['X-Tumblr-User' => 'test'], Stream::factory(json_encode(array()))), new Response(400, ['X-Tumblr-User' => 'test'], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$tumblr = new Tumblr('apikey');
$tumblr->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$tumblr->setLogger($logger);
// first test fail because we didn't match an url, so TumblrId isn't defined
$this->assertEmpty($tumblr->getContent());
$tumblr->match('http://thecodinglove.com/post/96365413702/client-giving-us-his-feedback-on-his-new-project');
// consecutive calls
$this->assertEquals('<div>content</div>', $tumblr->getContent());
// this one will got an empty array
$this->assertEmpty($tumblr->getContent());
// this one will catch an exception
$this->assertEmpty($tumblr->getContent());
$this->assertTrue($logHandler->hasWarning('Tumblr extract failed for: 96365413702 & thecodinglove.com'), 'Warning message matched');
}
示例11: testContent
public function testContent()
{
$client = new Client();
$mock = new Mock([new Response(200, [], Stream::factory(json_encode(array('title' => 'my title', 'thumbnail_url' => 'http://0.0.0.0/img.jpg', 'html' => '<iframe/>')))), new Response(200, [], Stream::factory('')), new Response(400, [], Stream::factory('oops'))]);
$client->getEmitter()->attach($mock);
$spotify = new Spotify();
$spotify->setClient($client);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$spotify->setLogger($logger);
// first test fail because we didn't match an url, so SpotifyUrl isn't defined
$this->assertEmpty($spotify->getContent());
$spotify->match('https://play.spotify.com/artist/4njdEjTnLfcGImKZu1iSrz');
// consecutive calls
$this->assertEquals('<div><h2>my title</h2><p><img src="http://0.0.0.0/img.jpg"></p><iframe/></div>', $spotify->getContent());
// this one will got an empty array
$this->assertEmpty($spotify->getContent());
// this one will catch an exception
$this->assertEmpty($spotify->getContent());
$this->assertTrue($logHandler->hasWarning('Spotify extract failed for: https://play.spotify.com/artist/4njdEjTnLfcGImKZu1iSrz'), 'Warning message matched');
}