/** * Since Mokka::mock() is static, this tests relies on the * correct function of the MockBuilder class */ public function testMockReturnsExpectedMockObject() { $mock = Mokka::mock('\\Mokka\\Tests\\ClassStub'); $this->assertInstanceOf('\\Mokka\\Tests\\ClassStub', $mock); $this->assertInstanceOf('\\Mokka\\Mock\\MockInterface', $mock); }
/** * @expectedException \InvalidArgumentException */ public function testSubbedMethodThrowsException() { $mock = Mokka::mock('\\Mokka\\Tests\\Integration\\Fixtures\\SampleClass'); Mokka::when($mock)->setBar()->thenThrow(new \InvalidArgumentException()); $mock->setBar(); }
/** * @expectedException \Mokka\VerificationException */ public function testVerifiesThatMethodWasNotCalled() { $mock = Mokka::mock('\\Mokka\\Tests\\Integration\\Fixtures\\SampleClass'); Mokka::verify($mock, new Never())->setBar(); $mock->setBar(); }