function testDefaultFrameTargetOnForm() { $page = new MockSimplePage(); $page->expectOnce('expandUrl', array(new SimpleUrl('here.php'))); $page->setReturnValue('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); }
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)); }
function testOnlyGettingFieldFromFocusedFrame() { $frame1 = new MockSimplePage(); $frame1->setReturnValue('getField', 'f', array(new SimpleByName('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 SimpleByName('a')), 'f'); }