Example #1
0
 public function testDefaultFrameTargetOnForm()
 {
     $page = new MockSimplePage();
     $page->expectOnce('expandUrl', array(new SimpleUrl('here.php')));
     $page->returnsByValue('expandUrl', new SimpleUrl('http://host/here.php'));
     $tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php'));
     $form = new SimpleForm($tag, $page);
     $form->setDefaultTarget('frame');
     $expected = new SimpleUrl('http://host/here.php');
     $expected->setTarget('frame');
     $this->assertEqual($form->getAction(), $expected);
 }
Example #2
0
 public function testOnlyGettingFieldFromFocusedFrame()
 {
     $frame1 = new MockSimplePage();
     $frame1->returnsByValue('getField', 'f', array(new SelectByName('a')));
     $frame2 = new MockSimplePage();
     $frame2->expectNever('getField');
     $frameset = new SimpleFrameset(new MockSimplePage());
     $frameset->addFrame($frame1, 'A');
     $frameset->addFrame($frame2, 'B');
     $frameset->setFrameFocus('A');
     $this->assertIdentical($frameset->getField(new SelectByName('a')), 'f');
 }
Example #3
0
 public 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->returnsByValue('getAction', new SimpleUrl('http://this.com/handler.html'));
     $form->returnsByValue('getMethod', 'post');
     $form->returnsByValue('submit', new SimplePostEncoding(array('a' => 'A')));
     $page = new MockSimplePage();
     $page->returns('getFormById', $form);
     $page->expectOnce('getFormById', array(33));
     $page->returnsByValue('getRaw', 'stuff');
     $browser = $this->createBrowser($agent, $page);
     $browser->get('http://this.com/page.html');
     $this->assertTrue($browser->submitFormById(33));
 }