/** * @param OpenCloud\ObjectStore\Service $objectStore * @param OpenCloud\ObjectStore\Resource\Container $container * @param OpenCloud\Common\Collection $objectList */ function it_returns_files_as_sorted_array($objectStore, $container, $objectList) { $inputArray = array('key5', 'key2', 'key1'); $outputArray = $inputArray; sort($outputArray); $index = 0; $objectList->next()->will(function () use($inputArray, &$index) { if ($index < count($inputArray)) { $objectItem = new \stdClass(); $objectItem->name = $inputArray[$index]; $index++; return $objectItem; } })->shouldBeCalledTimes(count($inputArray) + 1); $container->objectList()->willReturn($objectList); $objectStore->container("test")->willReturn($container); $this->keys()->shouldReturn($outputArray); }
/** * @param OpenCloud\ObjectStore\Service $objectStore */ function it_throws_exeption_if_container_creation_fails($objectStore) { $containerName = 'container-does-not-yet-exist'; $objectStore->getContainer($containerName)->willThrow(new BadResponseException()); $objectStore->createContainer($containerName)->willReturn(false); $this->beConstructedWith($objectStore, $containerName, true); $this->shouldThrow('\\RuntimeException')->duringExists('test'); }