Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TtlTest.php
Go to the documentation of this file.
1 <?php
7 
8 class TtlTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_model;
14 
18  protected $_config;
19 
20  protected function setUp()
21  {
23  ->create(\Magento\Framework\App\Config\ScopeConfigInterface::class);
25  ->create(\Magento\PageCache\Model\System\Config\Backend\Ttl::class);
26  }
27 
34  public function testBeforeSave($value, $path)
35  {
36  $this->_prepareData($value, $path);
37  }
38 
39  public function beforeSaveDataProvider()
40  {
41  return [
42  [125, 'ttl_1'],
43  [0, 'ttl_2'],
44  ];
45  }
46 
54  {
55  $this->expectException(\Magento\Framework\Exception\LocalizedException::class);
56  $this->_prepareData($value, $path);
57  }
58 
60  {
61  return [
62  ['', 'ttl_3'],
63  ['sdfg', 'ttl_4']
64  ];
65  }
66 
71  protected function _prepareData($value, $path)
72  {
73  $this->_model->setValue($value);
74  $this->_model->setPath($path);
75  $this->_model->setField($path);
76  $this->_model->save();
77  }
78 }
$value
Definition: gender.phtml:16