Example #1
0
    public function mainTest()
    {
        $tpl = new XNode('<html>
	<head>
		<title>Test page</title>
	</head>
	<body>
		<h1>Lorem ipsum</h1>		

		<div />

		<div>asd</div>

		<div id= "hello01" asdasdw />
<!--
		<div id= "hello02" asdasdw class="message" asdasd />
-->
		<hr>

		<div id="hello1" class="message"> Hello World! </div>

		<hr>

		<div id="hello2" class="message selected"> before <span>Hello World!</span> after </div>

		<hr>

		<div id="hello3" class="message"> before <div>Hello <span>here</span> World!</div> after </div>

		<hr>
		
		<input type="text" id="myinput1" value="my value here..">

	</body>
</html>');
        $before = $tpl->find('div#hello2.selected.message, div#hello1')->inner();
        $tpl->find('div#hello2.selected.message, div#hello1')->inner('yupeeee!');
        $after = $tpl->find('div#hello2.selected.message, div#hello1')->inner();
        $this->equ($before, ' Hello World! ');
        $this->equ($after, 'yupeeee!');
        $before = $tpl->find('html body input')->attr('value');
        $tpl->find('input')->attr('value', 'elembe!');
        $after = $tpl->find('html body input')->attr('value');
        $this->equ($before, 'my value here..');
        $this->equ($after, 'elembe!');
        $before = $tpl->outer();
        $this->equ(count($tpl('#hello02')->getElements()), 0);
        $after = $tpl->outer();
        $this->equ($before, $after);
        $this->equ(count($tpl('#hello02')->getElements()), $tpl->getCount('#hello02'));
    }