complete the tests for box api

This commit is contained in:
j3d1 2020-01-18 13:35:31 +01:00
parent 23c550428a
commit 7336606475
2 changed files with 55 additions and 0 deletions

View file

@ -61,4 +61,56 @@ class ContainerTest extends TestCase
$this->assertEquals(2, $response[0]['itemCount']); $this->assertEquals(2, $response[0]['itemCount']);
} }
public function testCreateContainer(){
$this->post('/1/box', ['name'=>'BOX']);
$response = $this->response->getOriginalContent();
$this->assertResponseStatus(201);
$this->assertEquals(1, $response['cid']);
$this->assertEquals('BOX', $response['name']);
$this->assertEquals(0, $response['itemCount']);
$boxes = Container::all();
$this->assertEquals(1, count($boxes));
$this->assertEquals(1, $boxes[0]['cid']);
$this->assertEquals('BOX', $boxes[0]['name']);
$this->assertEquals(0, $boxes[0]['itemCount']);
}
public function testUpdateContainer(){
$box = Container::create(['name'=>'BOX 1']);
$this->assertEquals(1, $box['cid']);
$this->assertEquals('BOX 1', $box['name']);
$this->assertEquals(0, $box['itemCount']);
$this->put('/1/box/'.$box->cid, ['name'=>'BOX 2']);
$response = $this->response->getOriginalContent();
$this->assertResponseOk();
$this->assertEquals(1, $response['cid']);
$this->assertEquals('BOX 2', $response['name']);
$this->assertEquals(0, $response['itemCount']);
$boxes = Container::all();
$this->assertEquals(1, count($boxes));
$this->assertEquals(1, $boxes[0]['cid']);
$this->assertEquals('BOX 2', $boxes[0]['name']);
$this->assertEquals(0, $boxes[0]['itemCount']);
}
public function testDeleteContainer(){
$box = Container::create(['name'=>'BOX 1']);
Container::create(['name'=>'BOX 2']);
$this->assertEquals(2, count(Container::all()));
$this->delete('/1/box/'.$box->cid);
$this->assertResponseOk();
$this->assertEquals(1, count(Container::all()));
}
} }

View file

@ -49,6 +49,7 @@ class EventTest extends TestCase
$this->post('/1/event', ['slug'=>'EVENT', 'name'=>'Event']); $this->post('/1/event', ['slug'=>'EVENT', 'name'=>'Event']);
$response = $this->response->getOriginalContent(); $response = $this->response->getOriginalContent();
$this->assertResponseStatus(201);
$this->assertEquals(1, $response['eid']); $this->assertEquals(1, $response['eid']);
$this->assertEquals('EVENT', $response['slug']); $this->assertEquals('EVENT', $response['slug']);
$this->assertEquals('Event', $response['name']); $this->assertEquals('Event', $response['name']);
@ -71,6 +72,7 @@ class EventTest extends TestCase
$this->put('/1/event/'.$event->eid, ['slug'=>'EVENT2', 'name'=>'Event 2']); $this->put('/1/event/'.$event->eid, ['slug'=>'EVENT2', 'name'=>'Event 2']);
$response = $this->response->getOriginalContent(); $response = $this->response->getOriginalContent();
$this->assertResponseOk();
$this->assertEquals(1, $response['eid']); $this->assertEquals(1, $response['eid']);
$this->assertEquals('EVENT2', $response['slug']); $this->assertEquals('EVENT2', $response['slug']);
$this->assertEquals('Event 2', $response['name']); $this->assertEquals('Event 2', $response['name']);
@ -95,6 +97,7 @@ class EventTest extends TestCase
$this->delete('/1/event/'.$event->eid); $this->delete('/1/event/'.$event->eid);
$this->assertResponseOk();
$this->assertEquals(1, count(Event::all())); $this->assertEquals(1, count(Event::all()));
} }