page_test.php.svn-base

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· SVN-BASE 代码 · 共 903 行 · 第 1/3 页

SVN-BASE
903
字号
        $response->setReturnValue(                'getContent',                '<html><frameset><frame src="a.html"></frameset></html>');        $response->setReturnValue('getUrl', new SimpleUrl('http://host/'));        $page = &$this->parse($response);        $this->assertTrue($page->hasFrames());        $this->assertIdentical(                $page->getFrameset(),                array(1 => new SimpleUrl('http://host/a.html')));    }    function testSingleFrameInNestedFrameset() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><frameset><frameset>' .                '<frame src="a.html">' .                '</frameset></frameset></html>');        $response->setReturnValue('getUrl', new SimpleUrl('http://host/'));        $page = &$this->parse($response);        $this->assertTrue($page->hasFrames());        $this->assertIdentical(                $page->getFrameset(),                array(1 => new SimpleUrl('http://host/a.html')));    }    function testFrameWithNoSource() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue(                'getContent',                '<html><frameset><frame></frameset></html>');        $page = &$this->parse($response);        $this->assertTrue($page->hasFrames());        $this->assertIdentical($page->getFrameset(), array());    }    function testFramesCollectedWithNestedFramesetTags() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><frameset>' .                '<frame src="a.html">' .                '<frameset><frame src="b.html"></frameset>' .                '<frame src="c.html">' .                '</frameset></html>');        $response->setReturnValue('getUrl', new SimpleUrl('http://host/'));        $page = &$this->parse($response);        $this->assertTrue($page->hasFrames());        $this->assertIdentical($page->getFrameset(), array(                1 => new SimpleUrl('http://host/a.html'),                2 => new SimpleUrl('http://host/b.html'),                3 => new SimpleUrl('http://host/c.html')));    }    function testNamedFrames() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><frameset>' .                '<frame src="a.html">' .                '<frame name="_one" src="b.html">' .                '<frame src="c.html">' .                '<frame src="d.html" name="_two">' .                '</frameset></html>');        $response->setReturnValue('getUrl', new SimpleUrl('http://host/'));        $page = &$this->parse($response);        $this->assertTrue($page->hasFrames());        $this->assertIdentical($page->getFrameset(), array(                1 => new SimpleUrl('http://host/a.html'),                '_one' => new SimpleUrl('http://host/b.html'),                3 => new SimpleUrl('http://host/c.html'),                '_two' => new SimpleUrl('http://host/d.html')));    }    function testFindFormByLabel() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue(                'getContent',                '<html><head><form><input type="submit"></form></head></html>');        $page = &$this->parse($response);        $this->assertNull($page->getFormBySubmit(new SimpleByLabel('submit')));        $this->assertNull($page->getFormBySubmit(new SimpleByName('submit')));        $this->assertIsA(                $page->getFormBySubmit(new SimpleByLabel('Submit')),                'SimpleForm');    }    function testConfirmSubmitAttributesAreCaseSensitive() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue(                'getContent',                '<html><head><FORM><INPUT TYPE="SUBMIT" NAME="S" VALUE="S"></FORM></head></html>');        $page = &$this->parse($response);        $this->assertIsA(                $page->getFormBySubmit(new SimpleByName('S')),                'SimpleForm');        $this->assertIsA(                $page->getFormBySubmit(new SimpleByLabel('S')),                'SimpleForm');    }    function testFindFormByImage() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<input type="image" id=100 alt="Label" name="me">' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertIsA(                $page->getFormByImage(new SimpleByLabel('Label')),                'SimpleForm');        $this->assertIsA(                $page->getFormByImage(new SimpleByName('me')),                'SimpleForm');        $this->assertIsA(                $page->getFormByImage(new SimpleById(100)),                'SimpleForm');    }    function testFindFormByButtonTag() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<button type="submit" name="b" value="B">BBB</button>' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertNull($page->getFormBySubmit(new SimpleByLabel('b')));        $this->assertNull($page->getFormBySubmit(new SimpleByLabel('B')));        $this->assertIsA(                $page->getFormBySubmit(new SimpleByName('b')),                'SimpleForm');        $this->assertIsA(                $page->getFormBySubmit(new SimpleByLabel('BBB')),                'SimpleForm');    }    function testFindFormById() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue(                'getContent',                '<html><head><form id="55"><input type="submit"></form></head></html>');        $page = &$this->parse($response);        $this->assertNull($page->getFormById(54));        $this->assertIsA($page->getFormById(55), 'SimpleForm');    }    function testReadingTextField() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<input type="text" name="a">' .                '<input type="text" name="b" value="bbb" id=3>' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertNull($page->getField(new SimpleByName('missing')));        $this->assertIdentical($page->getField(new SimpleByName('a')), '');        $this->assertIdentical($page->getField(new SimpleByName('b')), 'bbb');    }    function testReadingTextFieldIsCaseInsensitive() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><FORM>' .                '<INPUT TYPE="TEXT" NAME="a">' .                '<INPUT TYPE="TEXT" NAME="b" VALUE="bbb" id=3>' .                '</FORM></head></html>');        $page = &$this->parse($response);        $this->assertNull($page->getField(new SimpleByName('missing')));        $this->assertIdentical($page->getField(new SimpleByName('a')), '');        $this->assertIdentical($page->getField(new SimpleByName('b')), 'bbb');    }    function testSettingTextField() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<input type="text" name="a">' .                '<input type="text" name="b" id=3>' .                '<input type="submit">' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertTrue($page->setField(new SimpleByName('a'), 'aaa'));        $this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');        $this->assertTrue($page->setField(new SimpleById(3), 'bbb'));        $this->assertEqual($page->getField(new SimpleBYId(3)), 'bbb');        $this->assertFalse($page->setField(new SimpleByName('z'), 'zzz'));        $this->assertNull($page->getField(new SimpleByName('z')));    }    function testSettingTextFieldByEnclosingLabel() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<label>Stuff' .                '<input type="text" name="a" value="A">' .                '</label>' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertEqual($page->getField(new SimpleByName('a')), 'A');        $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');        $this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'aaa'));        $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'aaa');    }    function testGettingTextFieldByEnclosingLabelWithConflictingOtherFields() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<label>Stuff' .                '<input type="text" name="a" value="A">' .                '</label>' .                '<input type="text" name="b" value="B">' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertEqual($page->getField(new SimpleByName('a')), 'A');        $this->assertEqual($page->getField(new SimpleByName('b')), 'B');        $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');    }    function testSettingTextFieldByExternalLabel() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<label for="aaa">Stuff</label>' .                '<input id="aaa" type="text" name="a" value="A">' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');        $this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'aaa'));        $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'aaa');    }    function testReadingTextArea() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<textarea name="a">aaa</textarea>' .                '<input type="submit">' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');    }    function testSettingTextArea() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<textarea name="a">aaa</textarea>' .                '<input type="submit">' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertTrue($page->setField(new SimpleByName('a'), 'AAA'));        $this->assertEqual($page->getField(new SimpleByName('a')), 'AAA');    }    function testSettingSelectionField() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<select name="a">' .                '<option>aaa</option>' .                '<option selected>bbb</option>' .                '</select>' .                '<input type="submit">' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertEqual($page->getField(new SimpleByName('a')), 'bbb');        $this->assertFalse($page->setField(new SimpleByName('a'), 'ccc'));        $this->assertTrue($page->setField(new SimpleByName('a'), 'aaa'));        $this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');    }    function testSettingSelectionFieldByEnclosingLabel() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<label>Stuff' .                '<select name="a"><option selected>A</option><option>B</option></select>' .                '</label>' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');        $this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'B'));        $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'B');    }    function testSettingRadioButtonByEnclosingLabel() {        $response = &new MockSimpleHttpResponse();        $response->setReturnValue('getContent',                '<html><head><form>' .                '<label>A<input type="radio" name="r" value="a" checked></label>' .                '<label>B<input type="radio" name="r" value="b"></label>' .                '</form></head></html>');        $page = &$this->parse($response);        $this->assertEqual($page->getField(new SimpleByLabel('A')), 'a');        $this->assertTrue($page->setField(new SimpleBylabel('B'), 'b'));        $this->assertEqual($page->getField(new SimpleByLabel('B')), 'b');    }}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?