function testSubmitFormByFormId() { $agent = new MockSimpleUserAgent(); $agent->setReturnReference('fetchResponse', new MockSimpleHttpResponse()); $agent->expectArgumentsAt(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->setReturnReference('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 testFindingFormsByImage() { $frame = new MockSimplePage(); $form = new MockSimpleForm(); $frame->setReturnReference('getFormByImage', $form, array(new SimpleByLabel('a'))); $frameset = new SimpleFrameset(new MockSimplePage()); $frameset->addFrame(new MockSimplePage(), 'A'); $frameset->addFrame($frame, 'B'); $this->assertReference($frameset->getFormByImage(new SimpleByLabel('a')), $form); $frameset->setFrameFocus('A'); $this->assertNull($frameset->getFormByImage(new SimpleByLabel('a'))); $frameset->setFrameFocus('B'); $this->assertReference($frameset->getFormByImage(new SimpleByLabel('a')), $form); }