Exemplo n.º 1
0
 public function testBackwards()
 {
     $row = $this->getMockBuilder(Row::class)->disableOriginalConstructor()->getMock();
     $row->expects($this->once())->method('getPrimaryKey')->will($this->returnValue('film_id'));
     $row->expects($this->once())->method('offsetGet')->will($this->returnValue(-1));
     $query = $this->getMockBuilder(Query\Select::class)->disableOriginalConstructor()->getMock();
     $row->expects($this->once())->method('getQuery')->will($this->returnValue($query));
     $table = $this->getMockBuilder(Table::class)->disableOriginalConstructor()->getMock();
     $table->expects($this->once())->method('getRows')->will($this->returnValue([new Row($table, self::$filmCategories[0]), new Row($table, self::$filmCategories[1])]));
     $reference = new Reference($row, $table);
     $rows = $reference->backwards();
     $this->assertEquals(2, count($rows));
     $i = 0;
     foreach ($rows as $row) {
         $expected = self::$filmCategories[$i++];
         $this->assertInstanceOf(Row::class, $row);
         $this->assertEquals($expected, $row->toArray());
     }
 }