44
55use EasyMock \EasyMock ;
66use EasyMock \Test \Fixture \ClassFixture ;
7+ use EasyMock \Test \Fixture \CustomException ;
8+ use EasyMock \Test \Fixture \InterfaceFixture ;
79
810/**
911 * @author Matthieu Napoli <matthieu@mnapoli.fr>
@@ -15,6 +17,7 @@ class MockClassTest extends \PHPUnit_Framework_TestCase
1517 */
1618 public function should_mock_objects ()
1719 {
20+ /** @var ClassFixture $mock */
1821 $ mock = EasyMock::mock ('EasyMock\Test\Fixture\ClassFixture ' );
1922
2023 $ this ->assertInstanceOf ('PHPUnit_Framework_MockObject_MockObject ' , $ mock );
@@ -26,12 +29,24 @@ public function should_mock_objects()
2629 */
2730 public function should_mock_interfaces ()
2831 {
32+ /** @var InterfaceFixture $mock */
2933 $ mock = EasyMock::mock ('EasyMock\Test\Fixture\InterfaceFixture ' );
3034
3135 $ this ->assertInstanceOf ('PHPUnit_Framework_MockObject_MockObject ' , $ mock );
3236 $ this ->assertNull ($ mock ->foo ());
3337 }
3438
39+ /**
40+ * @test
41+ */
42+ public function not_mocked_methods_should_return_null ()
43+ {
44+ /** @var ClassFixture $mock */
45+ $ mock = EasyMock::mock ('EasyMock\Test\Fixture\ClassFixture ' );
46+
47+ $ this ->assertNull ($ mock ->foo ());
48+ }
49+
3550 /**
3651 * @test
3752 */
@@ -62,12 +77,15 @@ public function should_mock_existing_method_with_a_callback()
6277
6378 /**
6479 * @test
80+ * @expectedException \EasyMock\Test\Fixture\CustomException
81+ * @expectedExceptionMessage My message
6582 */
66- public function not_mocked_methods_should_return_null ()
83+ public function should_mock_existing_method_to_throw_exception ()
6784 {
6885 /** @var ClassFixture $mock */
69- $ mock = EasyMock::mock ('EasyMock\Test\Fixture\ClassFixture ' );
70-
71- $ this ->assertSame (null , $ mock ->foo ());
86+ $ mock = EasyMock::mock ('EasyMock\Test\Fixture\ClassFixture ' , array (
87+ 'foo ' => new CustomException ('My message ' ),
88+ ));
89+ $ mock ->foo ();
7290 }
7391}
0 commit comments