Exemplo n.º 1
0
 public function testVia()
 {
     $rowTableName = 'film';
     $rowPrimary = 'film_id';
     $tablePrimary = 'language_id';
     $row = $this->getMockBuilder(Row::class)->disableOriginalConstructor()->getMock();
     $row->expects($this->once())->method('getForeignKey')->will($this->returnValue($tablePrimary));
     $query = $this->getMockBuilder(Query\Select::class)->disableOriginalConstructor()->getMock();
     $row->expects($this->once())->method('getQuery')->will($this->returnValue($query));
     $row->expects($this->once())->method('offsetGet')->with($this->equalTo($tablePrimary))->will($this->returnValue(1));
     $table = $this->getMockBuilder(Table::class)->disableOriginalConstructor()->getMock();
     $table->expects($this->once())->method('getPrimaryKey')->will($this->returnValue($tablePrimary));
     $table->expects($this->once())->method('getRows')->will($this->returnValue([new Row($table, self::$languages[1]), new Row($table, self::$languages[6])]));
     $reference = new Reference($row, $table);
     $via = $reference->via();
     $this->assertInstanceOf(Row::class, $via);
     $this->assertEquals(self::$languages[1], $via->toArray());
 }