SynonymGroupTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Search\Test\Unit\Model\ResourceModel;
  7. class SynonymGroupTest extends \PHPUnit\Framework\TestCase
  8. {
  9. public function testGetByScope()
  10. {
  11. $context = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class);
  12. $resources = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
  13. $connection = $this->getMockForAbstractClass(
  14. \Magento\Framework\DB\Adapter\AdapterInterface::class,
  15. [],
  16. '',
  17. false
  18. );
  19. $select = $this->createMock(\Magento\Framework\DB\Select::class);
  20. $connection->expects($this->exactly(2))->method('quoteIdentifier')->willReturn('quoted');
  21. $connection->expects($this->once())->method('select')->willReturn($select);
  22. $context->expects($this->once())->method('getResources')->willReturn($resources);
  23. $resources->expects($this->any())->method('getConnection')->willReturn($connection);
  24. $select->expects($this->once())->method('from')->willReturn($select);
  25. $select->expects($this->exactly(2))->method('where')->with('quoted=?', 0)->willReturn($select);
  26. $connection->expects($this->once())->method('fetchAll')->with($select);
  27. $resourceModel = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
  28. ->getObject(\Magento\Search\Model\ResourceModel\SynonymGroup::class, ['context' => $context]);
  29. $resourceModel->getByScope(0, 0);
  30. }
  31. }