コード例 #1
0
ファイル: DbTest.php プロジェクト: pradeep-wagento/magento2
 /**
  * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\DB\Adapter\Pdo\Mysql $adapter
  * @depends testSetAddOrder
  */
 public function testUnshiftOrder($adapter)
 {
     $this->collection->setConnection($adapter);
     $this->collection->addOrder('some_field', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
     $this->collection->unshiftOrder('other_field', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
     $this->collection->load();
     $selectOrders = $this->collection->getSelect()->getPart(\Magento\Framework\DB\Select::ORDER);
     $this->assertEquals('other_field ASC', (string) array_shift($selectOrders));
     $this->assertEquals('some_field ASC', (string) array_shift($selectOrders));
     $this->assertEmpty(array_shift($selectOrders));
 }
コード例 #2
0
ファイル: DbTest.php プロジェクト: koliaGI/magento2
 /**
  * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\DB\Adapter\Pdo\Mysql $adapter
  * @depends testSetAddOrder
  */
 public function testUnshiftOrder($adapter)
 {
     $renderer = $this->getSelectRenderer($this->objectManager);
     $select = new \Magento\Framework\DB\Select($adapter, $renderer);
     $adapter->expects($this->any())->method('select')->willReturn($select);
     $this->collection->setConnection($adapter);
     $this->collection->addOrder('some_field', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
     $this->collection->unshiftOrder('other_field', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
     $this->collection->load();
     $selectOrders = $this->collection->getSelect()->getPart(\Magento\Framework\DB\Select::ORDER);
     $this->assertEquals('other_field ASC', (string) array_shift($selectOrders));
     $this->assertEquals('some_field ASC', (string) array_shift($selectOrders));
     $this->assertEmpty(array_shift($selectOrders));
 }