public function testMarkupInValid() { $content = '{"messages":[{"type":"info","message":"The Content-Type was “text/html”. Using the HTML parser."},{"type":"info","message":"Using the schema for HTML with SVG 1.1, MathML 3.0, RDFa 1.1, and ITS 2.0 support."},{"type":"error","lastLine":1,"lastColumn":42,"firstColumn":35,"message":"Element “title” must not be empty.","extract":"ad><title></title></head","hiliteStart":10,"hiliteLength":8}]}'; $response = $this->getMock('Buzz\\Message\\MessageInterface'); $response->expects($this->once())->method("getContent")->will($this->returnValue($content)); $this->browser->expects($this->once())->method("post")->will($this->returnValue($response)); $this->assertFalse($this->validator->isMarkupValid("<!DOCTYPE html><html><head><title></title></head><body></body></html>")); }
public function testRequest() { $response = $this->getMock('Buzz\\Message\\Response'); $response->expects($this->atLeastOnce())->method('isSuccessful')->will($this->returnValue(true)); $response->expects($this->atLeastOnce())->method('getContent')->will($this->returnValue('foo')); $this->browser->expects($this->atLeastOnce())->method('post')->will($this->returnValue($response)); $result = $this->builder->configure(['url' => 'http://lolcathost', 'debug' => false])->setPath(sys_get_temp_dir())->build(); $this->assertInternalType('array', $result); $this->assertGreaterThan(0, count($result)); $this->assertEquals(['<info>PNG</info> http://yuml.me/foo', '<info>URL</info> http://yuml.me/edit/foo', '<info>PDF</info> http://yuml.me/foo', '<info>JSON</info> http://yuml.me/foo', '<info>SVG</info> http://yuml.me/foo'], $result); }
/** * @param string $url * @param string $method * @param string $headers * @param string $body * @param HttpResponse|null $response */ private function expectHttpRequest($url, $method, $headers, $body, HttpResponse $response = null) { $this->broswer->expects($this->once())->method('call')->with($url, $method, $headers, $body)->willReturn($response); }
/** * @expectedException \AlterEgo\Exception\BadResponseException * @expectedExceptionMessage error * @expectedExceptionCode 1 */ public function testAuthenticateWithBadResponse() { $this->browser->expects($this->once())->method('get')->with($this->prepareUrl('password', array('key' => $key = 'test', 'pass' => $pass = 123456)))->will($this->returnValue($this->getResponseMock(500, array('code' => 1, 'message' => 'error')))); $this->client->authenticate($key, $pass); }