Checking forms


To further check if the page is correct we could check, using assertField(), if the form we expect to be on the page has the input fields as we expect them. We can even check if they have the correct preset values.


examples/php/simpletest/web05.php
<?php

require_once(dirname(__FILE__) . '/../../../tools/simpletest/autorun.php');
require_once(dirname(__FILE__) . '/../../../tools/simpletest/web_tester.php');


class TestOfCalculator extends WebTestCase {
    function testBasicCalc() {
        $url = 'http://localhost:8081/php/calc/basic_calc.php';
        $this->assertTrue($this->get($url));
        $this->assertText('Basic Calculator');
        $this->assertTitle('Scientific Calculator');

        $this->assertField('a', '');
        $this->assertField('b', '');
    }
}

?>

Unfortunately due to external limitations currently this code cannot recognize if there are more than one forms on the page and will mash them together for our purposes.