Skip to content

Commit

Permalink
Update api to support tenant module and tenant data model.
Browse files Browse the repository at this point in the history
  • Loading branch information
maso committed Nov 9, 2017
1 parent 4ab4ab9 commit 22d95a6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
30 changes: 15 additions & 15 deletions src/Tenant/urls.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* Tenant
*/
array(
'regex' => '#^/current$#',
'regex' => '#^/tenant/current$#',
'model' => 'Tenant_Views',
'method' => 'current',
'http-method' => 'GET',
'precond' => array()
),
array(
'regex' => '#^/current$#',
'regex' => '#^/tenant/current$#',
'model' => 'Tenant_Views',
'method' => 'update',
'http-method' => 'POST',
Expand All @@ -37,7 +37,7 @@
)
),
array(
'regex' => '#^/current$#',
'regex' => '#^/tenant/current$#',
'model' => 'Tenant_Views',
'method' => 'delete',
'http-method' => 'DELETE',
Expand All @@ -49,7 +49,7 @@
* Ticket
*/
array(
'regex' => '#^/current/ticket/find$#',
'regex' => '#^/ticket/find$#',
'model' => 'Pluf_Views',
'method' => 'findObject',
'http-method' => 'GET',
Expand Down Expand Up @@ -82,7 +82,7 @@
)
),
array(
'regex' => '#^/current/ticket/new$#',
'regex' => '#^/ticket/new$#',
'model' => 'Pluf_Views',
'method' => 'createObject',
'http-method' => 'POST',
Expand All @@ -94,7 +94,7 @@
)
),
array(
'regex' => '#^/current/ticket/(?P<modelId>\d+)$#',
'regex' => '#^/ticket/(?P<modelId>\d+)$#',
'model' => 'Pluf_Views',
'method' => 'getObject',
'http-method' => 'GET',
Expand All @@ -106,7 +106,7 @@
)
),
array(
'regex' => '#^/current/ticket/(?P<modelId>\d+)$#',
'regex' => '#^/ticket/(?P<modelId>\d+)$#',
'model' => 'Pluf_Views',
'method' => 'updateObject',
'http-method' => 'POST',
Expand All @@ -118,7 +118,7 @@
)
),
array(
'regex' => '#^/current/ticket/(?P<modelId>\d+)$#',
'regex' => '#^/ticket/(?P<modelId>\d+)$#',
'model' => 'Pluf_Views',
'method' => 'deleteObject',
'http-method' => 'DELETE',
Expand All @@ -133,7 +133,7 @@
* Comments of ticket
*/
array(
'regex' => '#^/current/ticket/(?P<parentId>\d+)/comment/find$#',
'regex' => '#^/ticket/(?P<parentId>\d+)/comment/find$#',
'model' => 'Pluf_Views',
'method' => 'findManyToOne',
'http-method' => 'GET',
Expand Down Expand Up @@ -168,7 +168,7 @@
)
),
array(
'regex' => '#^/current/ticket/(?P<parentId>\d+)/comment/new$#',
'regex' => '#^/ticket/(?P<parentId>\d+)/comment/new$#',
'model' => 'Pluf_Views',
'method' => 'createManyToOne',
'http-method' => 'POST',
Expand All @@ -182,7 +182,7 @@
)
),
array(
'regex' => '#^/current/ticket/(?P<parentId>\d+)/comment/(?P<modelId>\d+)$#',
'regex' => '#^/ticket/(?P<parentId>\d+)/comment/(?P<modelId>\d+)$#',
'model' => 'Pluf_Views',
'method' => 'getManyToOne',
'http-method' => 'GET',
Expand All @@ -196,7 +196,7 @@
)
),
array(
'regex' => '#^/current/ticket/(?P<parentId>\d+)/comment/(?P<modelId>\d+)$#',
'regex' => '#^/ticket/(?P<parentId>\d+)/comment/(?P<modelId>\d+)$#',
'model' => 'Pluf_Views',
'method' => 'updateManyToOne',
'http-method' => 'POST',
Expand All @@ -210,7 +210,7 @@
)
),
array(
'regex' => '#^/current/ticket/(?P<parentId>\d+)/comment/(?P<modelId>\d+)$#',
'regex' => '#^/ticket/(?P<parentId>\d+)/comment/(?P<modelId>\d+)$#',
'model' => 'Pluf_Views',
'method' => 'deleteManyToOne',
'http-method' => 'DELETE',
Expand All @@ -228,7 +228,7 @@
* invoices
*/
array(
'regex' => '#^/current/invoice/find$#',
'regex' => '#^/invoice/find$#',
'model' => 'Pluf_Views',
'method' => 'findObject',
'http-method' => 'GET',
Expand Down Expand Up @@ -261,7 +261,7 @@
)
),
array(
'regex' => '#^/current/invoice/(?P<modelId>\d+)$#',
'regex' => '#^/invoice/(?P<modelId>\d+)$#',
'model' => 'Pluf_Views',
'method' => 'getObject',
'http-method' => 'GET',
Expand Down
6 changes: 3 additions & 3 deletions tests/Tenant_REST/InvoicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testFindInvoices()
Test_Assert::assertResponseStatusCode($response, 200, 'Fail to login');

// find
$response = $client->get('/api/tenant/current/invoice/find');
$response = $client->get('/api/tenant/invoice/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response, 'Find result is not JSON paginated list');
Expand Down Expand Up @@ -156,7 +156,7 @@ public function testFindInvoicesNonEmpty()
$i->create();

// find
$response = $client->get('/api/tenant/current/invoice/find');
$response = $client->get('/api/tenant/invoice/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response, 'Find result is not JSON paginated list');
Expand Down Expand Up @@ -203,7 +203,7 @@ public function testGetInvoice()
$i->create();

// find
$response = $client->get('/api/tenant/current/invoice/'. $i->id);
$response = $client->get('/api/tenant/invoice/'. $i->id);
Test_Assert::assertResponseNotNull($response);
Test_Assert::assertResponseStatusCode($response, 200);
Test_Assert::assertResponseNotAnonymousModel($response, 'Invoice not foudn');
Expand Down
2 changes: 1 addition & 1 deletion tests/Tenant_REST/TenantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function testDefaultTenant()
'sub' => include 'Tenant/urls.php'
)
));
$response = $client->get('/api/tenant/current');
$response = $client->get('/api/tenant/tenant/current');
$this->assertNotNull($response);
$this->assertEquals($response->status_code, 200);
}
Expand Down
22 changes: 11 additions & 11 deletions tests/Tenant_REST/TicketCommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testFindTikcetComments()
$t->create();

// find comments
$response = $client->get('/api/tenant/current/ticket/' . $t->id . '/comment/find');
$response = $client->get('/api/tenant/ticket/' . $t->id . '/comment/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response, 'Find result is not JSON paginated list');
Expand Down Expand Up @@ -183,7 +183,7 @@ public function testFindTikcetCommentSNotEmpty()
$c->create();

// find comments
$response = $client->get('/api/tenant/current/ticket/' . $t->id . '/comment/find');
$response = $client->get('/api/tenant/ticket/' . $t->id . '/comment/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response);
Expand Down Expand Up @@ -242,7 +242,7 @@ public function testGetTikcetComment()
$c->create();

// find comments
$response = $client->get('/api/tenant/current/ticket/' . $t->id . '/comment/' . $c->id);
$response = $client->get('/api/tenant/ticket/' . $t->id . '/comment/' . $c->id);
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponseAsModel($response);
Expand Down Expand Up @@ -294,15 +294,15 @@ public function testCreateTikcetComment()
$t->create();

// find comments
$response = $client->post('/api/tenant/current/ticket/' . $t->id . '/comment/new', array(
$response = $client->post('/api/tenant/ticket/' . $t->id . '/comment/new', array(
'title' => 'test',
'description' => 'test'
));
Test_Assert::assertResponseStatusCode($response, 200);
$tc = json_decode($response->content, true);

// find comments
$response = $client->get('/api/tenant/current/ticket/' . $t->id . '/comment/find');
$response = $client->get('/api/tenant/ticket/' . $t->id . '/comment/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response);
Expand Down Expand Up @@ -355,22 +355,22 @@ public function testUpdateTikcetComment()
$t->create();

// find comments
$response = $client->post('/api/tenant/current/ticket/' . $t->id . '/comment/new', array(
$response = $client->post('/api/tenant/ticket/' . $t->id . '/comment/new', array(
'title' => 'test',
'description' => 'test'
));
Test_Assert::assertResponseStatusCode($response, 200);
$tc = json_decode($response->content, true);

// update
$response = $client->post('/api/tenant/current/ticket/' . $t->id . '/comment/' . $tc['id'], array(
$response = $client->post('/api/tenant/ticket/' . $t->id . '/comment/' . $tc['id'], array(
'title' => 'test new title',
'description' => 'test'
));
Test_Assert::assertResponseStatusCode($response, 200);

// find comments
$response = $client->get('/api/tenant/current/ticket/' . $t->id . '/comment/find');
$response = $client->get('/api/tenant/ticket/' . $t->id . '/comment/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response);
Expand Down Expand Up @@ -423,19 +423,19 @@ public function testDeleteTikcetComment()
$t->create();

// find comments
$response = $client->post('/api/tenant/current/ticket/' . $t->id . '/comment/new', array(
$response = $client->post('/api/tenant/ticket/' . $t->id . '/comment/new', array(
'title' => 'test',
'description' => 'test'
));
Test_Assert::assertResponseStatusCode($response, 200);
$tc = json_decode($response->content, true);

// update
$response = $client->delete('/api/tenant/current/ticket/' . $t->id . '/comment/' . $tc['id']);
$response = $client->delete('/api/tenant/ticket/' . $t->id . '/comment/' . $tc['id']);
Test_Assert::assertResponseStatusCode($response, 200);

// find comments
$response = $client->get('/api/tenant/current/ticket/' . $t->id . '/comment/find');
$response = $client->get('/api/tenant/ticket/' . $t->id . '/comment/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response);
Expand Down
18 changes: 9 additions & 9 deletions tests/Tenant_REST/TicketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function testFindTikcets()
Test_Assert::assertResponseStatusCode($response, 200, 'Fail to login');

// find teckets
$response = $client->get('/api/tenant/current/ticket/find');
$response = $client->get('/api/tenant/ticket/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response, 'Find result is not JSON paginated list');
Expand Down Expand Up @@ -149,7 +149,7 @@ public function testFindTikcetsNotEmpty()
Test_Assert::assertResponseStatusCode($response, 200, 'Fail to login');

// create tecket
$response = $client->post('/api/tenant/current/ticket/new', array(
$response = $client->post('/api/tenant/ticket/new', array(
'type' => 'bug',
'subject' => 'test ticket',
'description' => 'it is not possible to test',
Expand All @@ -160,14 +160,14 @@ public function testFindTikcetsNotEmpty()
$t = json_decode($response->content, true);

// find teckets
$response = $client->get('/api/tenant/current/ticket/find');
$response = $client->get('/api/tenant/ticket/find');
Test_Assert::assertResponseNotNull($response, 'Find result is empty');
Test_Assert::assertResponseStatusCode($response, 200, 'Find status code is not 200');
Test_Assert::assertResponsePaginateList($response, 'Find result is not JSON paginated list');
Test_Assert::assertResponseNonEmptyPaginateList($response, 'No ticket is created');

// delete ticket
$response = $client->delete('/api/tenant/current/ticket/' . $t['id']);
$response = $client->delete('/api/tenant/ticket/' . $t['id']);
Test_Assert::assertResponseStatusCode($response, 200, 'Ticket is removed');
}

Expand Down Expand Up @@ -200,7 +200,7 @@ public function testCreateTikcet()
Test_Assert::assertResponseStatusCode($response, 200, 'Fail to login');

// create tecket
$response = $client->post('/api/tenant/current/ticket/new', array(
$response = $client->post('/api/tenant/ticket/new', array(
'type' => 'bug',
'subject' => 'test ticket',
'description' => 'it is not possible to test',
Expand All @@ -211,7 +211,7 @@ public function testCreateTikcet()
$t = json_decode($response->content, true);

// delete ticket
$response = $client->delete('/api/tenant/current/ticket/' . $t['id']);
$response = $client->delete('/api/tenant/ticket/' . $t['id']);
Test_Assert::assertResponseStatusCode($response, 200, 'Ticket is removed');
}

Expand Down Expand Up @@ -246,7 +246,7 @@ public function testGetTikcet()
Test_Assert::assertResponseStatusCode($response, 200, 'Fail to login');

// create tecket
$response = $client->post('/api/tenant/current/ticket/new', array(
$response = $client->post('/api/tenant/ticket/new', array(
'type' => 'bug',
'subject' => 'test ticket',
'description' => 'it is not possible to test',
Expand All @@ -257,11 +257,11 @@ public function testGetTikcet()

// Get tecket
$t = json_decode($response->content, true);
$response = $client->get('/api/tenant/current/ticket/' . $t['id']);
$response = $client->get('/api/tenant/ticket/' . $t['id']);
Test_Assert::assertResponseNotAnonymousModel($response, 'Ticket is not find');

// delete ticket
$response = $client->delete('/api/tenant/current/ticket/' . $t['id']);
$response = $client->delete('/api/tenant/ticket/' . $t['id']);
Test_Assert::assertResponseStatusCode($response, 200, 'Ticket is removed');
}

Expand Down

0 comments on commit 22d95a6

Please sign in to comment.