From af68030fcf0c266300feb2c100149ecadef7d364 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 16 Jul 2006 01:50:23 +0000 Subject: Merge from 3.0 branch till 1264. --- .../docs/en/expectation_documentation.html | 40 ++++++++-------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'tests/test_tools/simpletest/docs/en/expectation_documentation.html') diff --git a/tests/test_tools/simpletest/docs/en/expectation_documentation.html b/tests/test_tools/simpletest/docs/en/expectation_documentation.html index 0165988c..bd189b94 100755 --- a/tests/test_tools/simpletest/docs/en/expectation_documentation.html +++ b/tests/test_tools/simpletest/docs/en/expectation_documentation.html @@ -23,9 +23,6 @@ Group tests
  • -Server stubs -
  • -
  • Mock objects
  • @@ -101,8 +98,8 @@
     class TestOfNewsService extends UnitTestCase {
         ...
    -    function testConnectionFailure() {
    -        $writer = &new MockWriter($this);
    +    function testConnectionFailure() {<strong>
    +        $writer = &new MockWriter();
             $writer->expectOnce('write', array(
                     'Cannot connect to news service ' .
                     '"BBC News" at this time. ' .
    @@ -110,8 +107,6 @@ class TestOfNewsService extends UnitTestCase {
             
             $service = &new NewsService('BBC News');
             $service->publish($writer);
    -        
    -        $writer->tally();
         }
     }
     
    @@ -129,15 +124,13 @@ class TestOfNewsService extends UnitTestCase { class TestOfNewsService extends UnitTestCase { ... function testConnectionFailure() { - $writer = &new MockWriter($this); + $writer = &new MockWriter(); $writer->expectOnce( 'write', - array(new WantedPatternExpectation('/cannot connect/i'))); + array(new PatternExpectation('/cannot connect/i'))); $service = &new NewsService('BBC News'); $service->publish($writer); - - $writer->tally(); } } @@ -179,10 +172,10 @@ class TestOfNewsService extends UnitTestCase { NotIndenticalExpectationInverts the mock object logic -WantedPatternExpectationUses a Perl Regex to match a string +PatternExpectationUses a Perl Regex to match a string -NoUnwantedPatternExpectationPasses only if failing a Perl Regex +NoPatternExpectationPasses only if failing a Perl Regex IsAExpectationChecks the type or class name only @@ -208,29 +201,26 @@ class TestOfNewsService extends UnitTestCase {

    The expectation classes can be used not just for sending assertions - from mock objects, but also for selecting behaviour for either - the - mock objects - or the - server stubs. + from mock objects, but also for selecting behaviour for the + mock objects. Anywhere a list of arguments is given, a list of expectation objects can be inserted instead.

    - Suppose we want an authorisation server stub to simulate a successful login + Suppose we want an authorisation server mock to simulate a successful login only if it receives a valid session object. We can do this as follows...

    -Stub::generate('Authorisation');
    +Mock::generate('Authorisation');
     
    -$authorisation = new StubAuthorisation();
    +$authorisation = new MockAuthorisation();
     $authorisation->setReturnValue(
             'isAllowed',
             true,
             array(new IsAExpectation('Session', 'Must be a session')));
     $authorisation->setReturnValue('isAllowed', false);
     
    - We have set the default stub behaviour to return false when + We have set the default mock behaviour to return false when isAllowed is called. When we call the method with a single parameter that is a Session object, it will return true. @@ -299,14 +289,14 @@ $authorisation->setReturnValue('isAllowed', false);

    The most crude way of doing this is to use the - SimpleTest::assertExpectation() method to + SimpleTest::assert() method to test against it directly...

     class TestOfNetworking extends UnitTestCase {
         ...
         function testGetValidIp() {
             $server = &new Server();
    -        $this->assertExpectation(
    +        $this->assert(
                     new ValidIp(),
                     $server->getIp(),
                     'Server IP address->%s');
    @@ -327,7 +317,7 @@ $authorisation->setReturnValue('isAllowed', false);
     class TestOfNetworking extends UnitTestCase {
         ...
         function assertValidIp($ip, $message = '%s') {
    -        $this->assertExpectation(new ValidIp(), $ip, $message);
    +        $this->assert(new ValidIp(), $ip, $message);
         }
         
         function testGetValidIp() {
    -- 
    cgit v1.2.3