createDirectoryResourceMock(); $resource ->expects($this->any()) ->method('getFilteredResources') ->will($this->returnValue(array( $foo = $this->createDirectoryResourceMock() ))); $resource ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(11)); $foo ->expects($this->any()) ->method('getFilteredResources') ->will($this->returnValue(array( $foobar = $this->createFileResourceMock() ))); $foo ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(22)); $foobar ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(33)); $checker = new DirectoryStateChecker($resource); $this->touchResource($resource, true, true); $this->touchResource($foo, true, true); $this->touchResource($foobar, true, false); $this->assertEquals(array( array('event' => FilesystemEvent::MODIFY, 'resource' => $foobar) ), $checker->getChangeset()); } public function testDeepFileDeleted() { $resource = $this->createDirectoryResourceMock(); $resource ->expects($this->any()) ->method('getFilteredResources') ->will($this->returnValue(array( $foo = $this->createDirectoryResourceMock() ))); $resource ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(11)); $foo ->expects($this->any()) ->method('getFilteredResources') ->will($this->onConsecutiveCalls( array($foobar = $this->createFileResourceMock(array(true, false))), array() )); $foo ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(22)); $foobar ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(33)); $checker = new DirectoryStateChecker($resource); $this->touchResource($resource, true, true); $this->touchResource($foo, true, true); $this->assertEquals(array( array('event' => FilesystemEvent::DELETE, 'resource' => $foobar) ), $checker->getChangeset()); } public function testDeepFileCreated() { $resource = $this->createDirectoryResourceMock(); $resource ->expects($this->any()) ->method('getFilteredResources') ->will($this->returnValue(array( $foo = $this->createDirectoryResourceMock() ))); $resource ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(11)); $foo ->expects($this->any()) ->method('getFilteredResources') ->will($this->onConsecutiveCalls( array(), array($foobar = $this->createFileResourceMock()) )); $foo ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(22)); $foobar ->expects($this->any()) ->method('getModificationTime') ->will($this->returnValue(33)); $checker = new DirectoryStateChecker($resource); $this->touchResource($resource, true, true); $this->touchResource($foo, true, true); $this->assertEquals(array( array('event' => FilesystemEvent::CREATE, 'resource' => $foobar) ), $checker->getChangeset()); } protected function touchResource(ResourceInterface $resource, $exists = true, $fresh = true) { if ($exists) { $resource ->expects($this->any()) ->method('isFresh') ->will($this->returnValue($fresh)); } else { $resource ->expects($this->any()) ->method('exists') ->will($this->returnValue(false)); } } protected function createDirectoryResourceMock($exists = true) { $resource = $this->getMockBuilder('Lurker\Resource\DirectoryResource') ->disableOriginalConstructor() ->getMock(); $this->setResourceExists($resource, $exists); return $resource; } protected function createFileResourceMock($exists = true) { $resource = $this->getMockBuilder('Lurker\Resource\FileResource') ->disableOriginalConstructor() ->getMock(); $this->setResourceExists($resource, $exists); return $resource; } protected function setResourceExists($resource, $exists) { if (is_array($exists)) { $resource ->expects($this->any()) ->method('exists') ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $exists)); } else { $resource ->expects($this->any()) ->method('exists') ->will($this->returnValue($exists)); } } } __halt_compiler();----SIGNATURE:----LYaeHnNbZ87ZeWEP5KUwnZqsVnTncZ/z5dWsPb5bEdtXi5rMYWjRVTtN3B2t41s/a+gwxLfVqTc2DhbMezlWabjeJN90f5VJANCRySpkUN5IVuz8fqgX3M8KQfKeiFWZ9tZc9Bd8Mu0CFfKI1SKXNr48Rh19ast23fqRpkelqrSYXqJbIjlaAutuCbl6x5qhokVv2MaU6eur5PoOy33Zv6svPcULEqZGhW/0CBnhhMM3jS7R1XNoMq/rt3J0KQhj9/td/nDuzFT/IfdbCOs0P9pGlQPN3s5/EI7R71QTFt1dDumyH+slgrC4L7VFvqyzsR+c9ueXHADPxfxybIzZ74rEmfa2d8aD6ifw/oaxLEBA+cP0dQedj2kuFEUyWQOy/3Z+JyowPcbQ1z5Mg2/xYjXXBq0MvxYv9AGozYAC1Fhc0t2/q9HEZWpkbgzj1Bu0XxUt5KteJMSpmjV7LNoZJRPak4QsF9YWiRx0Mvfql3/6YFHkMJ4uOyIemnPfYZ8Zjv/UUdMfdEAOPiGIowThM1SkIwrDnzknTaNadpQKj4lutgxWaV+lrTyy44rwSdCz2z6BToe3VIRL665Vj2Z95kLghNLCPNhPpWkUZkBXd2ci4a4k1DkPUi4XAZ9O4zQZxulni3Qdxdnl60ymLsXF9pyW/JZr71sESXTBDVRjHh8=----ATTACHMENT:----MjQ1NDI0ODg1NDkwNjI3OSA1NjM1NTQ0MzAwODAwNDA1IDYwNzIwMjMwNDM1OTQxNzQ=