| @@ 11-44 (lines=34) @@ | ||
| 8 | use GuzzleHttp\Psr7\Response; |
|
| 9 | use PhpSpec\ObjectBehavior; |
|
| 10 | ||
| 11 | class AddDirectorySpec extends ObjectBehavior |
|
| 12 | { |
|
| 13 | public function let(Client $client, HttpClient $http) |
|
| 14 | { |
|
| 15 | $client->getHttpClient()->willReturn($http); |
|
| 16 | $client->getProjectIdentifier()->willReturn('sylius'); |
|
| 17 | $client->getProjectApiKey()->willReturn('1234'); |
|
| 18 | $this->beConstructedWith($client); |
|
| 19 | } |
|
| 20 | ||
| 21 | public function it_should_be_an_api() |
|
| 22 | { |
|
| 23 | $this->shouldBeAnInstanceOf('Akeneo\Crowdin\Api\AbstractApi'); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function it_should_not_add_with_no_directory(HttpClient $http, Request $request, Response $response) |
|
| 27 | { |
|
| 28 | $content = '<xml></xml>'; |
|
| 29 | $response->getBody()->willReturn($content); |
|
| 30 | ||
| 31 | $http->post('project/sylius/add-directory?key=1234')->willReturn($response); |
|
| 32 | $this->shouldThrow('\InvalidArgumentException')->duringExecute(); |
|
| 33 | } |
|
| 34 | ||
| 35 | public function it_adds_a_directory(HttpClient $http, Request $request, Response $response) |
|
| 36 | { |
|
| 37 | $this->setDirectory('directory-to-create'); |
|
| 38 | $content = '<?xml version="1.0" encoding="ISO-8859-1"?><success></success>'; |
|
| 39 | $response->getBody()->willReturn($content); |
|
| 40 | $http->post('project/sylius/add-directory?key=1234', ['form_params' => ['name' => 'directory-to-create']])->willReturn($response); |
|
| 41 | ||
| 42 | $this->execute()->shouldBe($content); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 11-44 (lines=34) @@ | ||
| 8 | use GuzzleHttp\Psr7\Response; |
|
| 9 | use PhpSpec\ObjectBehavior; |
|
| 10 | ||
| 11 | class DeleteDirectorySpec extends ObjectBehavior |
|
| 12 | { |
|
| 13 | public function let(Client $client, HttpClient $http) |
|
| 14 | { |
|
| 15 | $client->getHttpClient()->willReturn($http); |
|
| 16 | $client->getProjectIdentifier()->willReturn('sylius'); |
|
| 17 | $client->getProjectApiKey()->willReturn('1234'); |
|
| 18 | $this->beConstructedWith($client); |
|
| 19 | } |
|
| 20 | ||
| 21 | public function it_should_be_an_api() |
|
| 22 | { |
|
| 23 | $this->shouldBeAnInstanceOf('Akeneo\Crowdin\Api\AbstractApi'); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function it_should_not_delete_with_no_directory(HttpClient $http, Request $request, Response $response) |
|
| 27 | { |
|
| 28 | $content = '<xml></xml>'; |
|
| 29 | $response->getBody()->willReturn($content); |
|
| 30 | ||
| 31 | $http->post('project/sylius/delete-directory?key=1234')->willReturn($response); |
|
| 32 | $this->shouldThrow('\InvalidArgumentException')->duringExecute(); |
|
| 33 | } |
|
| 34 | ||
| 35 | public function it_deletes_a_directory(HttpClient $http, Request $request, Response $response) |
|
| 36 | { |
|
| 37 | $this->setDirectory('directory-to-delete'); |
|
| 38 | $content = '<?xml version="1.0" encoding="ISO-8859-1"?><success></success>'; |
|
| 39 | $response->getBody()->willReturn($content); |
|
| 40 | $http->post('project/sylius/delete-directory?key=1234', ['form_params' => ['name' => 'directory-to-delete']])->willReturn($response); |
|
| 41 | ||
| 42 | $this->execute()->shouldBe($content); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 11-44 (lines=34) @@ | ||
| 8 | use GuzzleHttp\Psr7\Response; |
|
| 9 | use PhpSpec\ObjectBehavior; |
|
| 10 | ||
| 11 | class DeleteFileSpec extends ObjectBehavior |
|
| 12 | { |
|
| 13 | public function let(Client $client, HttpClient $http) |
|
| 14 | { |
|
| 15 | $client->getHttpClient()->willReturn($http); |
|
| 16 | $client->getProjectIdentifier()->willReturn('sylius'); |
|
| 17 | $client->getProjectApiKey()->willReturn('1234'); |
|
| 18 | $this->beConstructedWith($client); |
|
| 19 | } |
|
| 20 | ||
| 21 | public function it_should_be_an_api() |
|
| 22 | { |
|
| 23 | $this->shouldBeAnInstanceOf('Akeneo\Crowdin\Api\AbstractApi'); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function it_should_not_delete_with_no_file(HttpClient $http, Request $request, Response $response) |
|
| 27 | { |
|
| 28 | $content = '<xml></xml>'; |
|
| 29 | $response->getBody()->willReturn($content); |
|
| 30 | ||
| 31 | $http->post('project/sylius/delete-file?key=1234')->willReturn($response); |
|
| 32 | $this->shouldThrow('\InvalidArgumentException')->duringExecute(); |
|
| 33 | } |
|
| 34 | ||
| 35 | public function it_deletes_a_file(HttpClient $http, Request $request, Response $response) |
|
| 36 | { |
|
| 37 | $this->setFile('path/to/my/file'); |
|
| 38 | $content = '<?xml version="1.0" encoding="ISO-8859-1"?><success></success>'; |
|
| 39 | $response->getBody()->willReturn($content); |
|
| 40 | $http->post('project/sylius/delete-file?key=1234', ['form_params' => ['file' => 'path/to/my/file']])->willReturn($response); |
|
| 41 | ||
| 42 | $this->execute()->shouldBe($content); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||