c3lf-system-3/tests/ContainerTest.php
2020-01-18 01:28:21 +01:00

64 lines
1.8 KiB
PHP

<?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']);
}
}