public function testCanUseCustomItemRendering()
 {
     $request = Request::create('/', 'GET');
     $query = Sms::where('voip_id', 1);
     $doc = MasonCollection::make()->setItemRenderer(function (Request $request, Child $childDoc, Sms $sms) {
         $childDoc->setProperty('the_big_id', $sms->id);
     })->populate($request, $query);
     $this->assertNotEmpty($doc->items[0]->the_big_id);
 }
 public function testCanSortByCustomClosure()
 {
     $request = Request::create('/', 'GET', ['sort' => ['pogo' => 'desc']]);
     $query = Sms::where('voip_id', 1);
     $doc = (new MasonCollection($request, $query))->setSortTypes(['pogo' => function (Builder $query, $direction) {
         $query->orderBy('created', $direction);
     }])->assemble();
     $firstCreated = $doc->items[0]->created;
     $lastCreated = $doc->items[7]->created;
     $this->assertLessThan($firstCreated, $lastCreated);
 }
 public function testHumongousOffsetGivesZeroItems()
 {
     $request = Request::create('/', 'GET', ['offset' => 99999]);
     $query = Sms::where('voip_id', 1);
     $doc = (new MasonCollection($request, $query))->assemble();
     $this->assertEquals(0, count($doc->items));
 }
 public function testCanEscapeCommaInFilterParam()
 {
     $request = Request::create('/', 'GET', ['filter' => ['content' => 'contains:got it\\, lol']]);
     $query = Sms::where('voip_id', 1);
     $doc = (new MasonCollection($request, $query))->setFilterTypes(['content'])->assemble();
     $this->assertEquals(1, count($doc->items));
 }