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 = MasonCollection::make()->setSortTypes([Sort::make('pogo')->setFunction(function (Builder $query, $direction) {
         $query->orderBy('created', $direction);
     })])->populate($request, $query);
     $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 = MasonCollection::make()->populate($request, $query);
     $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 = MasonCollection::make()->setFilterTypes(['content'])->populate($request, $query);
     $this->assertEquals(1, count($doc->items));
 }