Ejemplo n.º 1
0
 public function testLimitAndOrderBy()
 {
     $db = new Database($this->pdo);
     $result = $db->order_by('year ASC')->limit(5)->select('albums');
     $this->assertEquals(5, count($result));
     $result = $db->order_by('year')->limit(1)->select('albums');
     $this->assertEquals(1, count($result));
     $this->assertEquals('Who\'s Next', $result[0]['name']);
     $this->assertEquals(1971, $result[0]['year']);
     $result = $db->order_by('year')->limit('1, 1')->select('albums');
     $this->assertEquals(1, count($result));
     $this->assertEquals('Siamese Dream', $result[0]['name']);
     $this->assertEquals(1993, $result[0]['year']);
     $result = $db->order_by('year DESC')->limit('1')->select('albums');
     $this->assertEquals(1, count($result));
     $this->assertEquals('Sleeping With Ghosts', $result[0]['name']);
     $this->assertEquals(2002, $result[0]['year']);
 }