Esempio n. 1
0
 public function testAuthenticationAccessors()
 {
     $headers = new MockSimpleHttpHeaders();
     $headers->returnsByValue('getAuthentication', 'Basic');
     $headers->returnsByValue('getRealm', 'Secret stuff');
     $response = new MockSimpleHttpResponse();
     $response->returnsByValue('getHeaders', $headers);
     $page = new SimplePage($response);
     $this->assertEqual($page->getAuthentication(), 'Basic');
     $this->assertEqual($page->getRealm(), 'Secret stuff');
 }
Esempio n. 2
0
 public function createUserAgent($pages)
 {
     $agent = new MockSimpleUserAgent();
     foreach ($pages as $url => $raw) {
         $url = new SimpleUrl($url);
         $response = new MockSimpleHttpResponse();
         $response->returnsByValue('getUrl', $url);
         $response->returnsByValue('getContent', $raw);
         $agent->returns('fetchResponse', $response, array($url, '*'));
     }
     return $agent;
 }
Esempio n. 3
0
 private function createSimulatedBadHost()
 {
     $response = new MockSimpleHttpResponse();
     $response->returnsByValue('isError', true);
     $response->returnsByValue('getError', 'Bad socket');
     $response->returnsByValue('getContent', false);
     $request = new MockSimpleHttpRequest();
     $request->returnsByReference('fetch', $response);
     return $request;
 }
Esempio n. 4
0
 public function whenVisiting($url, $content)
 {
     $response = new MockSimpleHttpResponse();
     $response->returnsByValue('getContent', $content);
     $response->returnsByValue('getUrl', new SimpleUrl($url));
     $builder = new SimpleTidyPageBuilder();
     return $builder->parse($response);
 }