Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WebsiteTest.php
Go to the documentation of this file.
1 <?php
7 
11 use Magento\Store\Model\WebsiteFactory;
12 
13 class WebsiteTest extends \PHPUnit\Framework\TestCase
14 {
18  protected $model;
19 
24 
28  protected $websiteFactory;
29 
30  public function setUp()
31  {
32  $this->objectManagerHelper = new ObjectManager($this);
33 
34  $this->websiteFactory = $this->getMockBuilder(\Magento\Store\Model\WebsiteFactory::class)
35  ->disableOriginalConstructor()
36  ->setMethods(['create', 'getCollection', '__wakeup'])
37  ->getMock();
38 
40  $this->model = $this->objectManagerHelper->getObject(
41  \Magento\Store\Model\Website::class,
42  ['websiteFactory' => $this->websiteFactory]
43  );
44  }
45 
46  public function testIsCanDelete()
47  {
48  $websiteCollection = $this->createPartialMock(
49  \Magento\Store\Model\ResourceModel\Website\Collection::class,
50  ['getSize']
51  );
52  $websiteCollection->expects($this->any())->method('getSize')->will($this->returnValue(2));
53 
54  $this->websiteFactory->expects($this->any())
55  ->method('create')
56  ->willReturn($this->websiteFactory);
57  $this->websiteFactory->expects($this->any())
58  ->method('getCollection')
59  ->willReturn($websiteCollection);
60 
61  $this->model->setId(2);
62  $this->assertTrue($this->model->isCanDelete());
63  }
64 
65  public function testGetScopeType()
66  {
67  $this->assertEquals(ScopeInterface::SCOPE_WEBSITE, $this->model->getScopeType());
68  }
69 
70  public function testGetScopeTypeName()
71  {
72  $this->assertEquals('Website', $this->model->getScopeTypeName());
73  }
74 }