From 73366605edd71f9ec0498efa91992fa30bb82463 Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 18 Jan 2020 01:28:21 +0100 Subject: [PATCH] add tests for box api --- tests/ContainerTest.php | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/ContainerTest.php 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']); + } + +}