add tests for files and refactor
This commit is contained in:
parent
b0cb0db558
commit
010282a7bb
6 changed files with 112 additions and 49 deletions
|
@ -25,7 +25,7 @@ class ItemTest extends TestCase
|
|||
{
|
||||
$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, 'description'=>'1']);
|
||||
|
||||
$this->get('/1/EVENT/items');
|
||||
$response = $this->response->getOriginalContent();
|
||||
|
@ -43,8 +43,8 @@ class ItemTest extends TestCase
|
|||
{
|
||||
$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']);
|
||||
$item = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'1']);
|
||||
$file = File::create(['iid'=>$item->iid, 'data'=>",".base64_encode("foo")]);
|
||||
|
||||
$this->get('/1/EVENT/items');
|
||||
$response = $this->response->getOriginalContent();
|
||||
|
@ -55,16 +55,16 @@ class ItemTest extends TestCase
|
|||
$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']);
|
||||
$this->assertEquals($file->hash, $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']);
|
||||
Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'1']);
|
||||
Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'2']);
|
||||
Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'3']);
|
||||
|
||||
$this->get('/1/EVENT/items');
|
||||
$response = $this->response->getOriginalContent();
|
||||
|
@ -110,7 +110,7 @@ class ItemTest extends TestCase
|
|||
|
||||
$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 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'1']);
|
||||
|
||||
$this->assertEquals(1, $item['uid']);
|
||||
$this->assertEquals('1', $item['description']);
|
||||
|
@ -138,8 +138,8 @@ class ItemTest extends TestCase
|
|||
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']);
|
||||
$item = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'1']);
|
||||
Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'2']);
|
||||
|
||||
$this->assertEquals(2, count(Item::all()));
|
||||
|
||||
|
@ -153,8 +153,8 @@ class ItemTest extends TestCase
|
|||
$event = Event::create(['slug'=>'EVENT','name'=>'Event']);
|
||||
$box = Container::create(['name'=>'BOX']);
|
||||
|
||||
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']);
|
||||
Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'1']);
|
||||
$item2 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'2']);
|
||||
|
||||
$this->assertEquals(2, count(Item::all()));
|
||||
|
||||
|
@ -163,7 +163,7 @@ class ItemTest extends TestCase
|
|||
$this->assertResponseOk();
|
||||
$this->assertEquals(1, count(Item::all()));
|
||||
|
||||
$item3 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'wann'=>'', 'wo'=>'','description'=>'3']);
|
||||
$item3 = Item::create(['cid'=>$box->cid, 'eid' => $event->eid, 'description'=>'3']);
|
||||
|
||||
$this->assertEquals(3, $item3['uid']);
|
||||
$this->assertEquals(2, count(Item::all()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue