Browse files

- Add some more tests.

  • Loading branch information...
1 parent b8f4d15 commit 09e2f2d6dbdd440cf737ea5ef6599297c90641d7 @sebastianbergmann committed Feb 7, 2007
Showing with 47 additions and 3 deletions.
  1. +47 −3 PHPUnit/Tests/Framework/MockObjectTest.php
View
50 PHPUnit/Tests/Framework/MockObjectTest.php
@@ -63,15 +63,59 @@
*/
class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
{
- public function testMockedMethodIsCalledOnceWithCorrectParameter()
+ public function testMockedMethodIsNeverCalled()
+ {
+ $mock = $this->getMock('AnInterface');
+ $mock->expects($this->never())
+ ->method('doSomething');
+ }
+
+ public function testMockedMethodIsCalledAtLeastOnce()
+ {
+ $mock = $this->getMock('AnInterface');
+ $mock->expects($this->atLeastOnce())
+ ->method('doSomething');
+
+ $mock->doSomething();
+ }
+
+ public function testMockedMethodIsCalledAtLeastOnce2()
+ {
+ $mock = $this->getMock('AnInterface');
+ $mock->expects($this->atLeastOnce())
+ ->method('doSomething');
+
+ $mock->doSomething();
+ $mock->doSomething();
+ }
+
+ public function testMockedMethodIsCalledOnce()
+ {
+ $mock = $this->getMock('AnInterface');
+ $mock->expects($this->once())
+ ->method('doSomething');
+
+ $mock->doSomething();
+ }
+
+ public function testMockedMethodIsCalledOnceWithParameter()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->once())
->method('doSomething')
- ->with($this->equalTo('something')
- );
+ ->with($this->equalTo('something'));
$mock->doSomething('something');
}
+
+ public function testMockedMethodIsCalledExactly()
+ {
+ $mock = $this->getMock('AnInterface');
+ $mock->expects($this->exactly(2))
+ ->method('doSomething');
+
+ $mock->doSomething();
+ $mock->doSomething();
+ }
}
?>

0 comments on commit 09e2f2d

Please sign in to comment.