Пример #1
0
 function testDefaultFrameTargetOnForm()
 {
     $tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php', 'id' => '33'));
     $form = new SimpleForm($tag, new SimpleUrl('http://host/a/index.html'));
     $form->setDefaultTarget('frame');
     $expected = new SimpleUrl('http://host/a/here.php');
     $expected->setTarget('frame');
     $this->assertEqual($form->getAction(), $expected);
 }
Пример #2
0
 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);
 }
Пример #3
0
 function testClickLinkWithUnknownFrameStillRequestsWholePage()
 {
     $agent = new MockSimpleUserAgent();
     $agent->returns('fetchResponse', new MockSimpleHttpResponse());
     $agent->expectAt(0, 'fetchResponse', array(new SimpleUrl('http://this.com/page.html'), new SimpleGetEncoding()));
     $target = new SimpleUrl('http://this.com/new.html');
     $target->setTarget('missing');
     $agent->expectAt(1, 'fetchResponse', array($target, new SimpleGetEncoding()));
     $agent->expectCallCount('fetchResponse', 2);
     $parsed_url = new SimpleUrl('http://this.com/new.html');
     $parsed_url->setTarget('missing');
     $page = new MockSimplePage();
     $page->setReturnValue('getUrlsByLabel', array($parsed_url));
     $page->setReturnValue('hasFrames', false);
     $page->expectOnce('getUrlsByLabel', array('New'));
     $page->setReturnValue('getRaw', 'A page');
     $browser = $this->createBrowser($agent, $page);
     $browser->get('http://this.com/page.html');
     $this->assertTrue($browser->clickLink('New'));
 }
Пример #4
0
 function testTargetAttachment()
 {
     $url = new SimpleUrl('http://www.site.com/home.html');
     $this->assertIdentical($url->getTarget(), false);
     $url->setTarget('A frame');
     $this->assertIdentical($url->getTarget(), 'A frame');
 }
Пример #5
0
 function testReadFrameTaggedUrlsFromFrameInFocus()
 {
     $frame =& new MockSimplePage();
     $by_label = new SimpleUrl('l');
     $by_label->setTarget('L');
     $frame->setReturnValue('getUrlsByLabel', array($by_label));
     $by_id = new SimpleUrl('i');
     $by_id->setTarget('I');
     $frame->setReturnValue('getUrlById', $by_id);
     $frameset =& new SimpleFrameset(new MockSimplePage());
     $frameset->addFrame($frame, 'A');
     $frameset->setFrameFocus('A');
     $this->assertIdentical($frameset->getUrlsByLabel('label'), array($by_label));
     $this->assertIdentical($frameset->getUrlById(99), $by_id);
 }