add tests for box api
This commit is contained in:
parent
2387082e88
commit
73366605ed
1 changed files with 64 additions and 0 deletions
64
tests/ContainerTest.php
Normal file
64
tests/ContainerTest.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Container;
|
||||||
|
use App\Event;
|
||||||
|
use App\Item;
|
||||||
|
|
||||||
|
class ContainerTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A basic test example.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function testEmpty()
|
||||||
|
{
|
||||||
|
$this->get('/1/boxes');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
$this->assertEquals('[]',$this->response->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMembers()
|
||||||
|
{
|
||||||
|
Container::create(['name'=>'BOX']);
|
||||||
|
|
||||||
|
$this->get('/1/boxes');
|
||||||
|
$response = $this->response->getOriginalContent();
|
||||||
|
|
||||||
|
$this->assertResponseOk();
|
||||||
|
$this->assertEquals(1, count($response));
|
||||||
|
$this->assertEquals(1, $response[0]['cid']);
|
||||||
|
$this->assertEquals('BOX', $response[0]['name']);
|
||||||
|
$this->assertEquals(0, $response[0]['itemCount']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testmultiMembers()
|
||||||
|
{
|
||||||
|
Container::create(['name'=>'BOX 1']);
|
||||||
|
Container::create(['name'=>'BOX 2']);
|
||||||
|
Container::create(['name'=>'BOX 3']);
|
||||||
|
|
||||||
|
$this->get('/1/boxes');
|
||||||
|
$response = $this->response->getOriginalContent();
|
||||||
|
|
||||||
|
$this->assertResponseOk();
|
||||||
|
$this->assertEquals(3, count($response));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testItemCount()
|
||||||
|
{
|
||||||
|
$event = Event::create(['slug'=>'EVENT','name'=>'Event']);
|
||||||
|
$box = Container::create(['name'=>'BOX']);
|
||||||
|
Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'item_uid'=>1, 'wann'=>'', 'wo'=>'','description'=>'1']);
|
||||||
|
Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'item_uid'=>2, 'wann'=>'', 'wo'=>'','description'=>'2']);
|
||||||
|
|
||||||
|
$this->get('/1/boxes');
|
||||||
|
$response = $this->response->getOriginalContent();
|
||||||
|
|
||||||
|
$this->assertResponseOk();
|
||||||
|
$this->assertEquals(1, count($response));
|
||||||
|
$this->assertEquals(2, $response[0]['itemCount']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue