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:----eE5bfF7vtnyF/VrDpiGv2eMNoHLHv2RqW1OHs7MIrVfTsIyJomaDo87HjfS6iij6yO5Yfoi6FIlOnrFkVwzv3OgxMfLt+v2V+bwkjAbdOBprSRao1PrcVXT0S1IEqmD557srrayeAhUjgkyc4fJOEStq6ODOkRVgFPAJenOmsLnXgFr6qBuqn6gPVcSOVIHEsoNbT9nOvlC/EcWOq13RrLEtm9aiX2gcmJEntXibS5muO0EQDHQY4p+qF69WftlVoYIw8WW+oV6/eh/amKnQQmk5dK/Q5OTaLzoDasshNWZ0xrjE1juGazZV9SIxmSB4/wqBaOdzOgzPe6UhWJfLerfEi3YZk2Znbkhc0KUW9qpeieDfzgcEzhFacYUN52mfuhHCIIMW4p5Xy7JKvizyTMRBZp1dzPR0l5Cg0fXzTNPHdHJT9SvyPQil3iJ2iZqkzdBiAweFa+WpIrE0PqZVFtwlIjeBDEDY5X3DtwRulSGjGv8tMAMRg+WHxjeRJq8/tMAgwGbQD/jNlHd1eyUwxSJn7LFXl4VpvTRPeeLin5+zVZ05rqOny1stUjwDbVQDtE50S7+15T82xxMxHr1CKjpRNse3KgqKQHEcSJH2Yq4ZPB+xPyPjeFWBzl4IrdSrQvZHZS29CYFizj5hKBdO/yiUV5K3Upku0ZNQpnyeOtI=----ATTACHMENT:----ODk4MDc3OTA3MDU5MDQ5MyA3ODEyNjk1NzYxNTU2MTY2IDI2NTQzNjU3NDQ0MjAzMTA=