diff options
| author | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-16 19:10:27 +0200 |
|---|---|---|
| committer | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-16 19:10:27 +0200 |
| commit | a3ff4d243e2ac37d4516ae56ff86985eadc00eb8 (patch) | |
| tree | 32e71c42855cc46d95d9c6b74ad2c145eb9ec7eb /server/vendor/php-opencloud/common/tests/unit/TestCase.php | |
| parent | 396c90f921c30de2d15d2ce52d5d1beabf8eb52d (diff) | |
| parent | 31d2d0c158ad4daa3dde7a905f3c2e312c194f2e (diff) | |
Test
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/unit/TestCase.php')
| -rwxr-xr-x | server/vendor/php-opencloud/common/tests/unit/TestCase.php | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/server/vendor/php-opencloud/common/tests/unit/TestCase.php b/server/vendor/php-opencloud/common/tests/unit/TestCase.php deleted file mode 100755 index 610d88a..0000000 --- a/server/vendor/php-opencloud/common/tests/unit/TestCase.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php - -namespace OpenCloud\Test; - -use function GuzzleHttp\Psr7\stream_for; -use function GuzzleHttp\Psr7\parse_response; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Psr7\Response; -use Prophecy\Argument; - -abstract class TestCase extends \PHPUnit_Framework_TestCase -{ - /** @var \Prophecy\Prophecy\ObjectProphecy */ - protected $client; - - /** @var string */ - protected $rootFixturesDir; - - protected $api; - - protected function setUp() - { - $this->client = $this->prophesize(ClientInterface::class); - } - - protected function createResponse($status, array $headers, array $json) - { - return new Response($status, $headers, stream_for(json_encode($json))); - } - - protected function getFixture($file) - { - if (!$this->rootFixturesDir) { - throw new \RuntimeException('Root fixtures dir not set'); - } - - $path = $this->rootFixturesDir . '/Fixtures/' . $file . '.resp'; - - if (!file_exists($path)) { - throw new \RuntimeException(sprintf("%s does not exist", $path)); - } - - return parse_response(file_get_contents($path)); - } - - protected function setupMock($method, $path, $body = null, array $headers = [], $response) - { - $options = ['headers' => $headers]; - - if (!empty($body)) { - $options[is_array($body) ? 'json' : 'body'] = $body; - } - - if (is_string($response)) { - $response = $this->getFixture($response); - } - - $this->client - ->request($method, $path, $options) - ->shouldBeCalled() - ->willReturn($response); - } - - protected function createFn($receiver, $method, $args) - { - return function () use ($receiver, $method, $args) { - return $receiver->$method($args); - }; - } - - protected function listTest(callable $call, $urlPath, $modelName = null, $responseFile = null) - { - $modelName = $modelName ?: $urlPath; - $responseFile = $responseFile ?: $urlPath; - - $this->setupMock('GET', $urlPath, null, [], $responseFile); - - $resources = call_user_func($call); - - $this->assertInstanceOf('\Generator', $resources); - - $count = 0; - - foreach ($resources as $resource) { - $this->assertInstanceOf('OpenStack\Identity\v3\Models\\' . ucfirst($modelName), $resource); - ++$count; - } - - $this->assertEquals(2, $count); - } - - protected function getTest(callable $call, $modelName) - { - $resource = call_user_func($call); - - $this->assertInstanceOf('OpenStack\Identity\v3\Models\\' . ucfirst($modelName), $resource); - $this->assertEquals('id', $resource->id); - } -} |
