'EVENT','name'=>'Event']); $this->get('/1/EVENT/items'); $this->assertResponseOk(); $this->assertEquals('[]',$this->response->getContent()); } public function testMembers() { $event = Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); $this->get('/1/EVENT/items'); $response = $this->response->getOriginalContent(); $this->assertResponseOk(); $this->assertEquals(1, count($response)); $this->assertEquals(1, $response[0]['uid']); $this->assertEquals('1', $response[0]['description']); $this->assertEquals($box->name, $response[0]['box']); $this->assertEquals($box->cid, $response[0]['cid']); $this->assertEquals(null, $response[0]['file']); } public function testMembersWithFile() { $event = Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); $item = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); File::create(['iid'=>$item->iid, 'hash'=>'filename']); $this->get('/1/EVENT/items'); $response = $this->response->getOriginalContent(); $this->assertResponseOk(); $this->assertEquals(1, count($response)); $this->assertEquals(1, $response[0]['uid']); $this->assertEquals('1', $response[0]['description']); $this->assertEquals($box->name, $response[0]['box']); $this->assertEquals($box->cid, $response[0]['cid']); $this->assertEquals('filename', $response[0]['file']); } public function testmultiMembers() { $event = Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'2']); Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'3']); $this->get('/1/EVENT/items'); $response = $this->response->getOriginalContent(); $this->assertResponseOk(); $this->assertEquals(3, count($response)); } public function testCreateItem(){ Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); $this->post('/1/EVENT/item',['cid'=>$box->cid, 'description'=>'1']); $response = $this->response->getOriginalContent(); $this->assertResponseStatus(201); $this->assertEquals(1, $response['uid']); $this->assertEquals('1', $response['description']); $this->assertEquals($box->name, $response['box']); $this->assertEquals($box->cid, $response['cid']); //$this->assertEquals('filename', $response['file']); $items = Item::all(); $this->assertEquals(1, count($items)); $this->assertEquals(1, $items[0]['uid']); $this->assertEquals('1', $items[0]['description']); $this->assertEquals($box->name, $items[0]['box']); $this->assertEquals($box->cid, $items[0]['cid']); //$this->assertEquals('filename', $items[0]['file']); } public function testCreateItemFail(){ Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); $this->post('/1/EVENT/item',[]); $response = $this->response->getOriginalContent(); $this->assertResponseStatus(500); } public function testUpdateItem(){ $event = Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); $item = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); $this->assertEquals(1, $item['uid']); $this->assertEquals('1', $item['description']); $this->assertEquals($box->cid, $item['cid']); $this->put('/1/EVENT/item/'.$item->uid,['description'=>'2']); $response = $this->response->getOriginalContent(); $this->assertResponseOk(); $this->assertEquals(1, $response['uid']); $this->assertEquals('2', $response['description']); $this->assertEquals($box->name, $response['box']); $this->assertEquals($box->cid, $response['cid']); //$this->assertEquals('filename', $response['file']); $items = Item::all(); $this->assertEquals(1, count($items)); $this->assertEquals(1, $items[0]['uid']); $this->assertEquals('2', $items[0]['description']); $this->assertEquals($box->name, $items[0]['box']); $this->assertEquals($box->cid, $items[0]['cid']); //$this->assertEquals('filename', $items[0]['file']); } public function testDeleteItem(){ $event = Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); $item = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'2']); $this->assertEquals(2, count(Item::all())); $this->delete('/1/EVENT/item/'.$item->uid); $this->assertResponseOk(); $this->assertEquals(1, count(Item::all())); } public function testDeleteItem2(){ $event = Event::create(['slug'=>'EVENT','name'=>'Event']); $box = Container::create(['name'=>'BOX']); $item1 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'1']); $item2 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'2']); $this->assertEquals(2, count(Item::all())); $this->delete('/1/EVENT/item/'.$item1->uid); $this->assertResponseOk(); $this->assertEquals(1, count(Item::all())); $item3 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'3']); $this->assertEquals(3, $item3['uid']); $this->assertEquals(2, count(Item::all())); $this->delete('/1/EVENT/item/'.$item2->uid); $this->assertResponseOk(); $this->assertEquals(1, count(Item::all())); } }