Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
DesignTest Class Reference
Inheritance diagram for DesignTest:

Public Member Functions

 testLoadChange ()
 
 testChangeDesign ()
 
 testCRUD ()
 
 testCollection ()
 
 loadChangeTimezoneDataProvider ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $_model
 

Detailed Description

Definition at line 11 of file DesignTest.php.

Member Function Documentation

◆ loadChangeTimezoneDataProvider()

loadChangeTimezoneDataProvider ( )

Depending on the current UTC time, either UTC-12:00, or UTC+12:00 timezone points to the different date. If UTC time is between 00:00 and 12:00, UTC+12:00 points to the same day, and UTC-12:00 to the previous day. If UTC time is between 12:00 and 24:00, UTC-12:00 points to the same day, and UTC+12:00 to the next day. Testing the design change with both UTC-12:00 and UTC+12:00 store timezones guarantees that the proper design change is chosen for the timezone with the date different from the UTC.

Definition at line 211 of file DesignTest.php.

212  {
220  return [
221  'default store - UTC+12:00' => ['default', 'Etc/GMT-12', '+12 hours'],
222  'default store - UTC-12:00' => ['default', 'Etc/GMT+12', '-12 hours'],
223  'admin store - UTC+12:00' => ['admin', 'Etc/GMT-12', '+12 hours'],
224  'admin store - UTC-12:00' => ['admin', 'Etc/GMT+12', '-12 hours']
225  ];
226  }

◆ setUp()

setUp ( )
protected

Definition at line 18 of file DesignTest.php.

19  {
21  \Magento\Theme\Model\Design::class
22  );
23  }

◆ testChangeDesign()

testChangeDesign ( )

@magentoDataFixture Magento/Theme/_files/design_change.php

Returns
void @covers \Magento\Theme\Model\Design::changeDesign @covers \Magento\Theme\Model\Design::__construct @covers \Magento\Theme\Model\Design::_construct

Definition at line 34 of file DesignTest.php.

35  {
37  ->setAreaCode('frontend');
39  \Magento\Framework\View\DesignInterface::class
40  );
42  \Magento\Store\Model\StoreManagerInterface::class
43  )->getDefaultStoreView()->getId();
44  // fixture design_change
46  \Magento\Theme\Model\Design::class
47  );
48  $designChange->loadChange($storeId)->changeDesign($design);
49  $this->assertEquals('Magento/luma', $design->getDesignTheme()->getThemePath());
50  }

◆ testCollection()

testCollection ( )
Todo:
fix and add addStoreFilter method

Definition at line 93 of file DesignTest.php.

94  {
95  $collection = $this->_model->getCollection()->joinStore()->addDateFilter();
99  $this->assertEmpty($collection->getItems());
100  }

◆ testCRUD()

testCRUD ( )

Definition at line 52 of file DesignTest.php.

53  {
54  $this->_model->setData(
55  [
56  'store_id' => 1,
57  'design' => 'Magento/blank',
58  'date_from' => date('Y-m-d', strtotime('-1 day')),
59  'date_to' => date('Y-m-d', strtotime('+1 day')),
60  ]
61  );
62  $this->_model->save();
63  $this->assertNotEmpty($this->_model->getId());
64 
65  try {
67  \Magento\Theme\Model\Design::class
68  );
69  $model->loadChange(1);
70  $this->assertEquals($this->_model->getId(), $model->getId());
71 
72  /* Design change that intersects with existing ones should not be saved, so exception is expected */
73  try {
74  $model->setId(null);
75  $model->save();
76  $this->fail('A validation failure is expected.');
77  } catch (\Magento\Framework\Exception\LocalizedException $e) {
78  }
79 
80  $this->_model->delete();
81  } catch (\Exception $e) {
82  $this->_model->delete();
83  throw $e;
84  }
85 
87  \Magento\Theme\Model\Design::class
88  );
89  $model->loadChange(1);
90  $this->assertEmpty($model->getId());
91  }

◆ testLoadChange()

testLoadChange ( )

Definition at line 25 of file DesignTest.php.

26  {
27  $this->_model->loadChange(1);
28  $this->assertNull($this->_model->getId());
29  }

Field Documentation

◆ $_model

$_model
protected

Definition at line 16 of file DesignTest.php.


The documentation for this class was generated from the following file: