Exemplo n.º 1
0
    }
    function testSpecificSequence()
    {
        $mock =& new MockDummy($this);
        $mock->setExpectedArgumentsSequence(1, "aMethod", array(1, 2, 3));
        $mock->setExpectedArgumentsSequence(2, "aMethod", array("Hello"));
        $mock->aMethod();
        $mock->aMethod(1, 2, 3);
        $mock->aMethod("Hello");
        $mock->aMethod();
    }
    function testFailedSequence()
    {
        $test =& new MockTestCase($this);
        $test->setExpectedArguments("assertTrue", array(false, "*"));
        $mock =& new MockDummy($test);
        $mock->setExpectedArgumentsSequence(0, "aMethod", array(1, 2, 3));
        $mock->setExpectedArgumentsSequence(1, "aMethod", array("Hello"));
        $mock->aMethod(1, 2);
        $mock->aMethod("Goodbye");
    }
}
$test = new SimpleTest("Mock components test");
$test->addTestCase(new TestOfParameterList());
$test->addTestCase(new TestOfCallMap());
$test->addTestCase(new TestOfCodeGeneration());
$test->addTestCase(new TestOfMockReturns());
$test->addTestCase(new TestOfMockTally());
$test->addTestCase(new TestOfMockExpectations());
$test->attachObserver(new TestHtmlDisplay());
$test->run();
Exemplo n.º 2
0
        $b = $a;
        $this->assertIdentical($a, $b);
        $a = "0";
        $b = 0;
        $this->assertIdentical($a, $b);
        // Fail.
    }
    function testOfReference()
    {
        $a = "fred";
        $b =& $a;
        $this->assertReference($a, $b);
        $c = "Hello";
        $this->assertReference($a, $c);
        // Fail.
    }
    function testOfPatterns()
    {
        $this->assertWantedPattern("Hello there", '/hello/i');
        $this->assertNoUnwantedPattern("Hello there", '/hello/');
        $this->assertWantedPattern("Hello there", '/hello/');
        // Fail.
        $this->assertNoUnwantedPattern("Hello there", '/hello/i');
        // Fail.
    }
}
$test = new SimpleTest("Unit test case test, 8 fails and 8 passes");
$display = new TestHTMLDisplay();
$test->attachObserver($display);
$test->addTestCase(new TestOfUnitTestCase());
$test->run();