Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QueryTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class QueryTest extends \PHPUnit\Framework\TestCase
11 {
15  private $model;
16 
20  private $resource;
21 
22  protected function setUp()
23  {
24  $objectManager = new ObjectManager($this);
25 
26  $this->resource = $this->getMockBuilder(\Magento\Search\Model\ResourceModel\Query::class)
27  ->disableOriginalConstructor()
28  ->getMock();
29 
30  $this->model = $objectManager->getObject(\Magento\Search\Model\Query::class, ['resource' => $this->resource]);
31  }
32 
33  public function testSaveNumResults()
34  {
35  $this->resource->expects($this->once())
36  ->method('saveNumResults')
37  ->with($this->model);
38 
39  $result = $this->model->saveNumResults(30);
40 
41  $this->assertEquals($this->model, $result);
42  $this->assertEquals(30, $this->model->getNumResults());
43  }
44 
46  {
47  $this->resource->expects($this->once())
48  ->method('saveIncrementalPopularity')
49  ->with($this->model);
50 
51  $result = $this->model->saveIncrementalPopularity();
52 
53  $this->assertEquals($this->model, $result);
54  }
55 }
$objectManager
Definition: bootstrap.php:17