From 2dc5d81371e4fb3c193577d9c763491835a79756 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 10 Jul 2018 03:20:14 -0300 Subject: [PATCH] right test json-dl --- tests/test-api-exposers.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/test-api-exposers.php b/tests/test-api-exposers.php index d6bdef5d0..8328ce6a7 100644 --- a/tests/test-api-exposers.php +++ b/tests/test-api-exposers.php @@ -8,6 +8,10 @@ namespace Tainacan\Tests; class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase { protected $item; protected $collection; + /** + * + * @var \Tainacan\Entities\Metadatum + */ protected $metadatum; protected function create_meta_requirements() { @@ -457,18 +461,6 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase { $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', @@ -477,9 +469,13 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase { $request->set_body($item_exposer_json); $response = $this->server->dispatch($request); $this->assertEquals(200, $response->get_status()); - $data = $response->get_data(); + $data = json_decode($response->get_data()); - var_dump($data); + $this->assertEquals('http://purl.org/dc/elements/1.1/', $data->{'@context'}->dc); + $this->assertEquals(get_locale(), $data->{'@context'}->{'@language'}); + $this->assertEquals($this->item->get('description'), $data->{'dc:description'}->{'@value'}); + $this->assertEquals($this->item->get('title'), $data->{'dc:title'}->{'@value'}); + $this->assertEquals('TestValues_exposers', $data->{'dc:language'}->{'@value'}); }