diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php new file mode 100644 index 0000000..32c6514 --- /dev/null +++ b/tests/ContainerTest.php @@ -0,0 +1,64 @@ +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']); + } + +}