function page($url, $action = false)
 {
     $page = new MockSimplePage();
     $page->returns('getUrl', new SimpleUrl($url));
     $page->returns('expandUrl', new SimpleUrl($url));
     return $page;
 }
Example #2
0
 function testSubmitFormByFormId()
 {
     $agent = new MockSimpleUserAgent();
     $agent->returns('fetchResponse', new MockSimpleHttpResponse());
     $agent->expectAt(1, 'fetchResponse', array(new SimpleUrl('http://this.com/handler.html'), new SimplePostEncoding(array('a' => 'A'))));
     $agent->expectCallCount('fetchResponse', 2);
     $form = new MockSimpleForm();
     $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
     $form->setReturnValue('getMethod', 'post');
     $form->setReturnValue('submit', new SimplePostEncoding(array('a' => 'A')));
     $page = new MockSimplePage();
     $page->returns('getFormById', $form);
     $page->expectOnce('getFormById', array(33));
     $page->setReturnValue('getRaw', 'stuff');
     $browser = $this->createBrowser($agent, $page);
     $browser->get('http://this.com/page.html');
     $this->assertTrue($browser->submitFormById(33));
 }
Example #3
0
 public function testFindingFormsByImage()
 {
     $frame = new MockSimplePage();
     $form = new MockSimpleForm();
     $frame->returns('getFormByImage', $form, array(new SelectByLabel('a')));
     $frameset = new SimpleFrameset(new MockSimplePage());
     $frameset->addFrame(new MockSimplePage(), 'A');
     $frameset->addFrame($frame, 'B');
     $this->assertSame($frameset->getFormByImage(new SelectByLabel('a')), $form);
     $frameset->setFrameFocus('A');
     $this->assertNull($frameset->getFormByImage(new SelectByLabel('a')));
     $frameset->setFrameFocus('B');
     $this->assertSame($frameset->getFormByImage(new SelectByLabel('a')), $form);
 }