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:----SDBfp7tFw+GOK5hMH1JOQOjkk6UJruUqVUFRkem9MBSUzVlgfW2QKrPM97oKmaQGaHIKZ/BoSysHSdS/A1uWZ/DqGOMZYhaW/zH39hafQ0JXRNZOd7446ER/G8Uwtidvk6otc9OnwvRugrLW4HVuDkXPK2t7Xh/GlOg3gozqcR8bhDwX4hrDSZWEX0THgBr3eFlAWw3gIntugAun7jAviEwXaWXuENIR9bFY5fI9fZzckmQEZNeubLCDyTHKu8u9fpWjBx9D0aVCR3YjPvBzqJ5RJBDr6ePgB+eusKVC6Zk57krdIC6Fp1T4yreSa0XxfE1TWApczJnQbJ+VjZE/Mrq5me+G1kc2oUodRQs00CGj/gEzT0PdfJnadP/hsU4skzBlFWU54qtmtPNk2CwwnBVb+jUI9Baz3Ftn+tlGPt8lf8XJj4inxNoOHGpCLAwX8/hAxby6k1ZSiVZclw1rbgE58lQgWXKqajY1jSyutHw3IO2aORVBhW5Lz826HIc6EliG7qxDKdfEjgmT1Ho3H5x4/bvNlD7TXozjMvPdtFKgyBFkbCyHBW7VdfzCzyvu/IHQyCDw+eIIcw61oII+LRShZlC6R6P+fRnwIvQ23VskC0BXMaL80vpNF6dSP/xTHZZUGPLX7noKkF9ONcSstbzj13WEYVPxCohGu7HWDp8=----ATTACHMENT:----NzYzNDkwMzA3OTE4OTU1IDI2MTEzMTE0NDM1NzY1MTEgODEwMTY4MDk0OTczNDQzOA==