Open Data Catalog v2.0.0
WebServiceApiTest.php
Go to the documentation of this file.
1 <?php
2 
3 use MockChain\Options;
5 use PHPUnit\Framework\TestCase;
6 use Symfony\Component\DependencyInjection\Container;
7 use MockChain\Chain;
9 use Symfony\Component\HttpFoundation\JsonResponse;
10 use Symfony\Component\HttpFoundation\Request;
11 use Symfony\Component\HttpFoundation\RequestStack;
12 
16 class WebServiceApiTest extends TestCase {
17 
21  public function testMultipleDrops() {
22  $container = $this->getContainer();
23 
24  $webServiceApi = WebServiceApi::create($container);
25  $result = $webServiceApi->deleteMultiple(["1", "2"]);
26 
27  $this->assertTrue($result instanceof JsonResponse);
28  }
29 
33  public function testMultipleImports() {
34  $container = $this->getContainer();
35 
36  $webServiceApi = WebServiceApi::create($container);
37  $result = $webServiceApi->import();
38 
39  $this->assertTrue($result instanceof JsonResponse);
40  }
41 
45  private function getContainer() {
46  $options = (new Options())
47  ->add("dkan_datastore.service", Service::class)
48  ->add("request_stack", RequestStack::class)
49  ->index(0);
50 
51  return (new Chain($this))
52  ->add(Container::class, "get", $options)
53  ->add(Service::class, "drop", NULL)
54  ->add(Service::class, "import", [])
55  ->add(RequestStack::class, 'getCurrentRequest', Request::class)
56  ->add(Request::class, 'getContent', json_encode((object) ['resource_ids' => ["1", "2"]]))
57  ->getMock();
58  }
59 
60 }
WebServiceApiTest\testMultipleImports
testMultipleImports()
Definition: WebServiceApiTest.php:33
WebServiceApiTest\testMultipleDrops
testMultipleDrops()
Definition: WebServiceApiTest.php:21
Drupal\dkan_datastore\WebServiceApi
Definition: WebServiceApi.php:17
WebServiceApiTest
Definition: WebServiceApiTest.php:16
Drupal\dkan_datastore\Service