1212namespace Brainbits \Blocking \Tests \Adapter ;
1313
1414use Brainbits \Blocking \Adapter \FilesystemAdapter ;
15+ use Brainbits \Blocking \Owner \OwnerInterface ;
1516use PHPUnit_Framework_TestCase as TestCase ;
1617use org \bovigo \vfs \vfsStream ;
1718use Brainbits \Blocking \Block ;
1819use Brainbits \Blocking \Identifier \Identifier ;
20+ use Prophecy \Prophecy \ObjectProphecy ;
1921
2022/**
2123 * Filesystem adapter test
@@ -34,19 +36,20 @@ class FilesystemAdapterTest extends TestCase
3436 */
3537 private $ root ;
3638
39+ /**
40+ * @var OwnerInterface|ObjectProphecy
41+ */
42+ private $ ownerMock ;
43+
3744 public function setUp ()
3845 {
3946 vfsStream::setup ('blockDir ' );
4047
4148 $ this ->root = vfsStream::url ('blockDir ' );
4249 $ this ->adapter = new FilesystemAdapter ($ this ->root );
43- $ this ->ownerMock = $ this ->getMockBuilder ('Brainbits\Blocking\Owner\OwnerInterface ' )
44- ->disableOriginalConstructor ()
45- ->getMock ();
46- $ this ->ownerMock
47- ->expects ($ this ->any ())
48- ->method ('__toString ' )
49- ->will ($ this ->returnValue ('dummyOwner ' ));
50+
51+ $ this ->ownerMock = $ this ->prophesize (OwnerInterface::class);
52+ $ this ->ownerMock ->__toString ()->willReturn ('dummyOwner ' );
5053 }
5154
5255 public function tearDown ()
@@ -59,7 +62,7 @@ public function tearDown()
5962 public function testWriteSucceedesOnNewFile ()
6063 {
6164 $ identifier = new Identifier ('test ' , 'lock ' );
62- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
65+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
6366
6467 $ result = $ this ->adapter ->write ($ block );
6568
@@ -76,7 +79,7 @@ public function testWriteFailsOnNonExistantDirectoryInNonWritableDirectory()
7679 $ adapter = new FilesystemAdapter (vfsStream::url ('nonWritableDir/blockDir ' ));
7780
7881 $ identifier = new Identifier ('test ' , 'lock ' );
79- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
82+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
8083
8184 $ adapter ->write ($ block );
8285 }
@@ -92,7 +95,7 @@ public function testWriteFailsOnNonWritableDirectory()
9295 $ adapter = new FilesystemAdapter (vfsStream::url ('writableDir/nonWritableBlockDir ' ));
9396
9497 $ identifier = new Identifier ('test ' , 'lock ' );
95- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
98+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
9699
97100 $ adapter ->write ($ block );
98101 }
@@ -104,7 +107,7 @@ public function testWriteFailsOnNonWritableDirectory()
104107 public function testTouchSucceedesOnExistingFile ()
105108 {
106109 $ identifier = new Identifier ('test ' , 'lock ' );
107- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
110+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
108111
109112 $ this ->adapter ->write ($ block );
110113 $ result = $ this ->adapter ->touch ($ block );
@@ -116,7 +119,7 @@ public function testTouchSucceedesOnExistingFile()
116119 public function testRemoveReturnsFalseOnNonexistingFile ()
117120 {
118121 $ identifier = new Identifier ('test ' , 'unlock ' );
119- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
122+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
120123
121124 $ result = $ this ->adapter ->remove ($ block );
122125
@@ -127,7 +130,7 @@ public function testRemoveReturnsFalseOnNonexistingFile()
127130 public function testUnblockReturnsTrueOnExistingFile ()
128131 {
129132 $ identifier = new Identifier ('test ' , 'unlock ' );
130- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
133+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
131134
132135 $ this ->adapter ->write ($ block );
133136 $ result = $ this ->adapter ->remove ($ block );
@@ -148,7 +151,7 @@ public function testExistsReturnsFalseOnNonexistingFile()
148151 public function testIsBlockedReturnsTrueOnExistingBlock ()
149152 {
150153 $ identifier = new Identifier ('test ' , 'isblocked ' );
151- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
154+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
152155
153156 $ this ->adapter ->write ($ block );
154157 $ result = $ this ->adapter ->exists ($ identifier );
@@ -168,7 +171,7 @@ public function testGetReturnsNullOnNonexistingFile()
168171 public function testGetReturnsBlockOnExistingFile ()
169172 {
170173 $ identifier = new Identifier ('test ' , 'isblocked ' );
171- $ block = new Block ($ identifier , $ this ->ownerMock , new \DateTime ());
174+ $ block = new Block ($ identifier , $ this ->ownerMock -> reveal () , new \DateTime ());
172175
173176 $ this ->adapter ->write ($ block );
174177 $ result = $ this ->adapter ->get ($ identifier );
0 commit comments