public function test_it_uploads_to_a_nested_sub_dir_in_a_container() { $baseUrl = 'foo.com/bar'; $containerMock = $this->prophet->prophesize('OpenCloud\\ObjectStore\\Resource\\Container'); $iteratorMock = $this->prophet->prophesize('OpenCloud\\Common\\Collection\\PaginatedIterator'); $iteratorMock->rewind()->shouldBeCalled(); $iteratorMock->populateAll()->shouldBeCalled(); $iteratorMock->valid()->willReturn(false); $iteratorMock->search(Argument::type('callable'))->willReturn(false); $containerMock->getUrl()->willReturn(Url::factory($baseUrl)); $guzzleMock = $this->prophet->prophesize('Guzzle\\Http\\Client'); $guzzleMock->put($baseUrl . '/sub-dir/test1', [], Argument::type('Guzzle\\Http\\EntityBody'))->shouldBeCalled(); $guzzleMock->send(Argument::that(function ($array) { return count($array) === 1; }))->shouldBeCalled(); $containerMock->getClient()->willReturn($guzzleMock->reveal()); $sync = new DirectorySync(); $sync->setBasePath(__DIR__ . '/fixtures'); $sync->setContainer($containerMock->reveal()); $sync->setRemoteFiles($iteratorMock->reveal()); $sync->setTargetDir('sub-dir'); $sync->execute(); }
/** * Upload the contents of a local directory to a remote container, effectively syncing them. * * @param $path The local path to the directory. */ public function uploadDirectory($path) { $sync = DirectorySync::factory($path, $this); $sync->execute(); }
/** * Upload the contents of a local directory to a remote container, effectively syncing them. * * @param string $path The local path to the directory. * @param string $targetDir The path (or pseudo-directory) that all files will be nested in. */ public function uploadDirectory($path, $targetDir = null) { $sync = DirectorySync::factory($path, $this, $targetDir); $sync->execute(); }