@@ -20,55 +20,54 @@ class EasyMockTest extends TestCase
2020 /**
2121 * @test
2222 */
23- public function should_mock_objects ()
23+ public function should_mock_objects (): void
2424 {
2525 /** @var ClassFixture $mock */
26- $ mock = $ this ->easyMock (' EasyMock\Test\Fixture\ ClassFixture' );
26+ $ mock = $ this ->easyMock (ClassFixture::class );
2727
28- $ this ->assertInstanceOf ('PHPUnit\Framework\MockObject\MockObject ' , $ mock );
2928 $ this ->assertNull ($ mock ->foo ());
3029 }
3130
3231 /**
3332 * @test
3433 */
35- public function should_skip_the_constructor ()
34+ public function should_skip_the_constructor (): void
3635 {
3736 /** @var ClassWithConstructor $mock */
38- $ mock = $ this ->easyMock ('\EasyMock\Test\Fixture\ClassWithConstructor ' );
37+ $ mock = $ this ->easyMock (ClassWithConstructor::class);
38+
3939 $ this ->assertFalse ($ mock ->constructorCalled );
4040 }
4141
4242 /**
4343 * @test
4444 */
45- public function should_mock_interfaces ()
45+ public function should_mock_interfaces (): void
4646 {
4747 /** @var InterfaceFixture $mock */
48- $ mock = $ this ->easyMock (' EasyMock\Test\Fixture\ InterfaceFixture' );
48+ $ mock = $ this ->easyMock (InterfaceFixture::class );
4949
50- $ this ->assertInstanceOf ('PHPUnit\Framework\MockObject\MockObject ' , $ mock );
5150 $ this ->assertNull ($ mock ->foo ());
5251 }
5352
5453 /**
5554 * @test
5655 */
57- public function not_mocked_methods_should_return_null ()
56+ public function not_mocked_methods_should_return_null (): void
5857 {
5958 /** @var ClassFixture $mock */
60- $ mock = $ this ->easyMock (' EasyMock\Test\Fixture\ ClassFixture' );
59+ $ mock = $ this ->easyMock (ClassFixture::class );
6160
6261 $ this ->assertNull ($ mock ->foo ());
6362 }
6463
6564 /**
6665 * @test
6766 */
68- public function should_mock_existing_method_with_a_value ()
67+ public function should_mock_existing_method_with_a_value (): void
6968 {
7069 /** @var ClassFixture $mock */
71- $ mock = $ this ->easyMock (' EasyMock\Test\Fixture\ ClassFixture' , array (
70+ $ mock = $ this ->easyMock (ClassFixture::class , array (
7271 'foo ' => 'bar ' ,
7372 ));
7473
@@ -78,10 +77,10 @@ public function should_mock_existing_method_with_a_value()
7877 /**
7978 * @test
8079 */
81- public function should_mock_existing_method_with_a_callback ()
80+ public function should_mock_existing_method_with_a_callback (): void
8281 {
8382 /** @var ClassFixture $mock */
84- $ mock = $ this ->easyMock (' EasyMock\Test\Fixture\ ClassFixture' , array (
83+ $ mock = $ this ->easyMock (ClassFixture::class , array (
8584 'foo ' => function () {
8685 return 'bar ' ;
8786 },
@@ -92,25 +91,27 @@ public function should_mock_existing_method_with_a_callback()
9291
9392 /**
9493 * @test
95- * @expectedException \EasyMock\Test\Fixture\CustomException
96- * @expectedExceptionMessage My message
9794 */
98- public function should_mock_existing_method_to_throw_exception ()
95+ public function should_mock_existing_method_to_throw_exception (): void
9996 {
10097 /** @var ClassFixture $mock */
101- $ mock = $ this ->easyMock (' EasyMock\Test\Fixture\ ClassFixture' , array (
98+ $ mock = $ this ->easyMock (ClassFixture::class , array (
10299 'foo ' => new CustomException ('My message ' ),
103100 ));
101+
102+ $ this ->expectException (CustomException::class);
103+ $ this ->expectExceptionMessage ('My message ' );
104+
104105 $ mock ->foo ();
105106 }
106107
107108 /**
108109 * @test
109110 */
110- public function should_mock_new_methods_on_existing_mock ()
111+ public function should_mock_new_methods_on_existing_mock (): void
111112 {
112113 /** @var ClassFixture $mock */
113- $ mock = $ this ->easyMock (' EasyMock\Test\Fixture\ ClassFixture' );
114+ $ mock = $ this ->easyMock (ClassFixture::class );
114115 $ mock = $ this ->easyMock ($ mock , array (
115116 'foo ' => 'bar ' ,
116117 ));
@@ -121,14 +122,15 @@ public function should_mock_new_methods_on_existing_mock()
121122 /**
122123 * @test
123124 */
124- public function should_allow_to_spy_method_calls ()
125+ public function should_allow_to_spy_method_calls (): void
125126 {
126- $ mock = $ this ->easySpy ('EasyMock\Test\Fixture\ClassFixture ' , array (
127+ /** @var ClassFixture $mock */
128+ $ mock = $ this ->easySpy (ClassFixture::class, array (
127129 'foo ' => 'bar ' ,
128130 ));
129131
130132 // Test PHPUnit's internals to check that the spy was registered
131- $ property = new \ReflectionProperty (' \PHPUnit\Framework\ TestCase' , 'mockObjects ' );
133+ $ property = new \ReflectionProperty (TestCase::class , 'mockObjects ' );
132134 $ property ->setAccessible (true );
133135 $ mockObjects = $ property ->getValue ($ this );
134136
@@ -140,7 +142,7 @@ public function should_allow_to_spy_method_calls()
140142 $ mock ->__phpunit_verify ();
141143 $ this ->fail ('Exception not thrown ' );
142144 } catch (ExpectationFailedException $ e ) {
143- $ this ->assertContains ('Expected invocation at least once but it never occur ' , $ e ->getMessage ());
145+ $ this ->assertStringContainsString ('Expected invocation at least once but it never occur ' , $ e ->getMessage ());
144146 }
145147
146148 // Invoke the mock: the test should now pass
0 commit comments