1515use Brainbits \Blocking \Identity \IdentityInterface ;
1616use Brainbits \Blocking \Owner \OwnerInterface ;
1717use DateTimeImmutable ;
18+ use PHPUnit \Framework \MockObject \MockObject ;
1819use PHPUnit \Framework \TestCase ;
19- use Prophecy \PhpUnit \ProphecyTrait ;
20- use Prophecy \Prophecy \ObjectProphecy ;
2120
22- /**
23- * Block test
24- */
2521class BlockTest extends TestCase
2622{
27- use ProphecyTrait;
28-
2923 /**
30- * @var IdentityInterface|ObjectProphecy
24+ * @var IdentityInterface|MockObject
3125 */
3226 private $ identifier ;
3327
3428 /**
35- * @var OwnerInterface|ObjectProphecy
29+ * @var OwnerInterface|MockObject
3630 */
3731 private $ owner ;
3832
3933 protected function setUp (): void
4034 {
41- $ this ->identifier = $ this ->prophesize (IdentityInterface::class)-> reveal ( );
35+ $ this ->identifier = $ this ->createMock (IdentityInterface::class);
4236
43- $ this ->owner = $ this ->prophesize (OwnerInterface::class);
44- $ this ->owner ->__toString ()
37+ $ this ->owner = $ this ->createMock (OwnerInterface::class);
38+ $ this ->owner ->expects ($ this ->any ())
39+ ->method ('__toString ' )
4540 ->willReturn ('dummyOwner ' );
4641 }
4742
4843 public function testConstruct (): void
4944 {
50- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , new DateTimeImmutable ());
45+ $ block = new Block ($ this ->identifier , $ this ->owner , new DateTimeImmutable ());
5146
5247 $ this ->assertInstanceOf (Block::class, $ block );
5348 }
5449
5550 public function testGetIdentifierReturnsCorrectValue (): void
5651 {
57- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , new DateTimeImmutable ());
52+ $ block = new Block ($ this ->identifier , $ this ->owner , new DateTimeImmutable ());
5853
5954 $ this ->assertSame ($ this ->identifier , $ block ->getIdentity ());
6055 }
6156
6257 public function testGetOwnerReturnsCorrectValue (): void
6358 {
64- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , new DateTimeImmutable ());
59+ $ block = new Block ($ this ->identifier , $ this ->owner , new DateTimeImmutable ());
6560
66- $ this ->assertSame ($ this ->owner -> reveal () , $ block ->getOwner ());
61+ $ this ->assertSame ($ this ->owner , $ block ->getOwner ());
6762 }
6863
6964 public function testIsOwnedByReturnsTrue (): void
7065 {
71- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , new DateTimeImmutable ());
66+ $ block = new Block ($ this ->identifier , $ this ->owner , new DateTimeImmutable ());
7267
73- $ this ->owner ->equals ($ this ->owner ->reveal ())
68+ $ this ->owner ->expects ($ this ->once ())
69+ ->method ('equals ' )
70+ ->with ($ this ->owner )
7471 ->willReturn (true );
7572
76- $ this ->assertTrue ($ block ->isOwnedBy ($ this ->owner -> reveal () ));
73+ $ this ->assertTrue ($ block ->isOwnedBy ($ this ->owner ));
7774 }
7875
7976 public function testIsOwnedByReturnsFalse (): void
8077 {
81- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , new DateTimeImmutable ());
78+ $ block = new Block ($ this ->identifier , $ this ->owner , new DateTimeImmutable ());
8279
83- $ owner = $ this ->prophesize (OwnerInterface::class);
84- $ owner ->__toString ()
80+ $ owner = $ this ->createMock (OwnerInterface::class);
81+ $ this ->owner ->expects ($ this ->any ())
82+ ->method ('__toString ' )
8583 ->willReturn ('dummyOwner ' );
8684
87- $ this ->owner ->equals ($ owner ->reveal ())
88- ->willReturn (false );
85+ $ this ->owner ->expects ($ this ->once ())
86+ ->method ('equals ' )
87+ ->with ($ owner )
88+ ->willReturn (false );
8989
90- $ this ->assertFalse ($ block ->isOwnedBy ($ owner-> reveal () ));
90+ $ this ->assertFalse ($ block ->isOwnedBy ($ owner ));
9191 }
9292
9393 public function testGetCreatedAtReturnsCorrectValue (): void
9494 {
9595 $ createdAt = new DateTimeImmutable ();
9696
97- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , $ createdAt );
97+ $ block = new Block ($ this ->identifier , $ this ->owner , $ createdAt );
9898 $ result = $ block ->getCreatedAt ();
9999
100100 $ this ->assertInstanceOf (DateTimeImmutable::class, $ result );
@@ -105,7 +105,7 @@ public function testGetUpdatedAtReturnsCreatedAtValueAfterInstanciation(): void
105105 {
106106 $ createdAt = new DateTimeImmutable ();
107107
108- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , $ createdAt );
108+ $ block = new Block ($ this ->identifier , $ this ->owner , $ createdAt );
109109 $ result = $ block ->getUpdatedAt ();
110110
111111 $ this ->assertInstanceOf (DateTimeImmutable::class, $ result );
@@ -116,7 +116,7 @@ public function testTouchUpdatesValue(): void
116116 {
117117 $ createdAt = new DateTimeImmutable ();
118118
119- $ block = new Block ($ this ->identifier , $ this ->owner -> reveal () , $ createdAt );
119+ $ block = new Block ($ this ->identifier , $ this ->owner , $ createdAt );
120120
121121 $ updatedAt = new DateTimeImmutable ();
122122
0 commit comments