From 118765ed951054dba4bea25e02038c2f58e825df Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 9 Jul 2018 18:23:45 -0300 Subject: [PATCH] add prototype of jsondl test case --- tests/test-api-exposers.php | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/test-api-exposers.php b/tests/test-api-exposers.php index fea9062ef..d6bdef5d0 100644 --- a/tests/test-api-exposers.php +++ b/tests/test-api-exposers.php @@ -433,6 +433,56 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase { } + /** + * @group json_dl_exposer + */ + public function test_jsondl_exposer() { + global $Tainacan_Metadata, $Tainacan_Item_Metadata; + + extract($this->create_meta_requirements()); + + $item__metadata_json = json_encode([ + 'values' => 'TestValues_exposers', + ]); + + $request = new \WP_REST_Request('POST', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/' . $this->metadatum->get_id() ); + $request->set_body($item__metadata_json); + + $response = $this->server->dispatch($request); + + $this->assertEquals(200, $response->get_status()); + + $data = $response->get_data(); + + $this->assertEquals($this->item->get_id(), $data['item']['id']); + $this->assertEquals('TestValues_exposers', $data['value']); + + /*$item_exposer_json = json_encode([ + 'exposer-type' => 'json-ld', + ]); + + $request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/'. $this->metadatum->get_id() ); + $request->set_body($item_exposer_json); + $response = $this->server->dispatch($request); + $this->assertEquals(200, $response->get_status()); + $data = $response->get_data(); + + var_dump($data);*/ + + $item_exposer_json = json_encode([ + 'exposer-type' => 'json-ld', + 'exposer_map' => 'dublin-core', + ]); + $request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' ); + $request->set_body($item_exposer_json); + $response = $this->server->dispatch($request); + $this->assertEquals(200, $response->get_status()); + $data = $response->get_data(); + + var_dump($data); + + } + } ?> \ No newline at end of file