Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SalableResolverTest.php
Go to the documentation of this file.
1 <?php
8 
9 class SalableResolverTest extends \PHPUnit\Framework\TestCase
10 {
14  protected $object;
15 
19  protected $product;
20 
21  protected function setUp()
22  {
23  $this->product = $this->createPartialMock(
24  \Magento\Catalog\Model\Product::class,
25  ['__wakeup', 'getCanShowPrice']
26  );
27 
28  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
29  $this->object = $objectManager->getObject(
30  \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver::class
31  );
32  }
33 
34  public function testSalableItem()
35  {
36  $this->product->expects($this->any())
37  ->method('getCanShowPrice')
38  ->willReturn(true);
39 
40  $result = $this->object->isSalable($this->product);
41  $this->assertTrue($result);
42  }
43 
44  public function testNotSalableItem()
45  {
46  $this->product->expects($this->any())
47  ->method('getCanShowPrice')
48  ->willReturn(false);
49 
50  $result = $this->object->isSalable($this->product);
51  $this->assertFalse($result);
52  }
53 }
$objectManager
Definition: bootstrap.php:17