/** * We want to test that the file is unlinked */ public function testCreateResourceFromPath() { $resourceName = 'js_75a9295_bootstrap-modal_3.js'; $resourceContainerName = 'liuggio_assetic'; $path = 'rscf://' . $resourceContainerName . '/' . $resourceName; $object = $this->getMockBuilder('\\OpenCloud\\ObjectStore\\Resource\\Container')->disableOriginalConstructor()->setMethods(array('setName'))->getMock(); $object->expects($this->once())->method('setName')->with($this->equalTo($resourceName)); $container = $this->getMockBuilder('\\OpenCloud\\ObjectStore\\Resource\\Container')->disableOriginalConstructor()->getMock(); $container->expects($this->once())->method('dataObject')->will($this->returnValue($object)); $this->objectStore->expects($this->once())->method('getContainer')->with($this->equalTo('liuggio_assetic'))->will($this->returnValue($container)); $resource = new RackspaceCloudFilesResource(); $resource->setResourceName($resourceName); $resource->setContainerName($resourceContainerName); $resource->setObject($object); $resource->setContainer($container); $resource->setCurrentPath($path); $ret = $this->RSCFService->createResourceFromPath($path); $this->assertEquals($ret, $resource); }
public function testMkdir() { //testing that the API create_paths is called //we want to test that the file is unlinked $resourceName = 'js_75a9295_bootstrap-modal_3.js'; $resourceContainerName = 'liuggio_assetic'; $path = 'rscf://' . $resourceContainerName . '/' . $resourceName; // assert that delete_object is called with the correct name $phpunit = $this; $container = $this->getMock('\\StdClass', array('create_paths')); $container->expects($this->any())->method('create_paths')->will($this->returnCallback(function ($path) use($phpunit, $resourceName) { $phpunit->assertEquals($resourceName, $path); return true; })); $resource = new RackspaceCloudFilesResource(); $resource->setResourceName($resourceName); $resource->setContainerName($resourceContainerName); $resource->setContainer($container); //mocking sw $streamWrapper = $this->getMock($this->streamWrapperClass, array('getResource', 'initFromPath')); $streamWrapper->expects($this->any())->method('getResource')->will($this->returnValue($resource)); $streamWrapper->expects($this->any())->method('initFromPath')->will($this->returnValue(true)); // the call $ret = $streamWrapper->mkdir($path, '', ''); $this->assertTrue($ret !== false); }