|
@@ -0,0 +1,64 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Tests\tripal_ws\http;
|
|
|
+
|
|
|
+use StatonLab\TripalTestSuite\DBTransaction;
|
|
|
+use StatonLab\TripalTestSuite\TripalTestCase;
|
|
|
+
|
|
|
+class TripalContentTest extends TripalTestCase{
|
|
|
+
|
|
|
+ // Uncomment to auto start and rollback db transactions per test method.
|
|
|
+ use DBTransaction;
|
|
|
+
|
|
|
+ /** @test */
|
|
|
+ public function testGettingMainContentList() {
|
|
|
+ //call /web-services/content/v0.1
|
|
|
+ $response = $this->get('/web-services/content/v0.1');
|
|
|
+
|
|
|
+ // Make sure it returned valid json
|
|
|
+ $response->assertSuccessful();
|
|
|
+ $response->assertJsonStructure([
|
|
|
+ '@context',
|
|
|
+ '@id',
|
|
|
+ '@type',
|
|
|
+ 'label',
|
|
|
+ 'totalItems',
|
|
|
+ 'member' => [
|
|
|
+ [
|
|
|
+ '@id',
|
|
|
+ '@type',
|
|
|
+ 'label',
|
|
|
+ 'description',
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** @test */
|
|
|
+ public function testGettingListOfEntitiesInABundle() {
|
|
|
+ // Get bundle label
|
|
|
+ $label = db_query('SELECT label FROM tripal_bundle LIMIT 1')->fetchField();
|
|
|
+
|
|
|
+ // Call /web-services/content/v0.1/[label]
|
|
|
+ $response = $this->get("/web-services/content/v0.1/$label");
|
|
|
+
|
|
|
+ // Verify the returned JSON matches the structure
|
|
|
+ $response->assertSuccessful();
|
|
|
+ $response->assertJsonStructure([
|
|
|
+ '@context',
|
|
|
+ '@id',
|
|
|
+ '@type',
|
|
|
+ 'label',
|
|
|
+ 'totalItems',
|
|
|
+ 'member',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ // Verify the collection is of the correct type
|
|
|
+ $json = $response->json();
|
|
|
+ $this->assertEquals($json['label'], "$label Collection");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testGettingAFeatureResource() {
|
|
|
+ // Call /web-services/content/v0.1/mRNA/1428
|
|
|
+ }
|
|
|
+}
|