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

Public Member Functions

 testConvertNoJobs ()
 
 testConvertConfigParams ()
 
 testConvertRunConfig ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $_converter
 

Detailed Description

Definition at line 8 of file DbTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Prepare parameters

Definition at line 18 of file DbTest.php.

19  {
20  $this->_converter = new \Magento\Cron\Model\Config\Converter\Db();
21  }

◆ testConvertConfigParams()

testConvertConfigParams ( )

Testing parameters in 'schedule' container

Definition at line 36 of file DbTest.php.

37  {
38  $fullJob = ['schedule' => ['config_path' => 'config/path', 'cron_expr' => '* * * * *']];
39  $nullJob = ['schedule' => ['config_path' => null, 'cron_expr' => null]];
40  $notFullJob = ['schedule' => ''];
41  $source = [
42  'crontab' => [
43  'default' => [
44  'jobs' => [
45  'job_name_1' => $fullJob,
46  'job_name_2' => $nullJob,
47  'job_name_3' => $notFullJob,
48  'job_name_4' => [],
49  ],
50  ],
51  ],
52  ];
53  $expected = [
54  'default' => [
55  'job_name_1' => ['config_path' => 'config/path', 'schedule' => '* * * * *'],
56  'job_name_2' => ['config_path' => null, 'schedule' => null],
57  'job_name_3' => ['schedule' => ''],
58  'job_name_4' => [''],
59  ],
60  ];
61 
62  $result = $this->_converter->convert($source);
63  $this->assertEquals(
64  $expected['default']['job_name_1']['config_path'],
65  $result['default']['job_name_1']['config_path']
66  );
67  $this->assertEquals(
68  $expected['default']['job_name_1']['schedule'],
69  $result['default']['job_name_1']['schedule']
70  );
71 
72  $this->assertEquals(
73  $expected['default']['job_name_2']['config_path'],
74  $result['default']['job_name_2']['config_path']
75  );
76  $this->assertEquals(
77  $expected['default']['job_name_2']['schedule'],
78  $result['default']['job_name_2']['schedule']
79  );
80 
81  $this->assertArrayHasKey('schedule', $result['default']['job_name_3']);
82  $this->assertEmpty($result['default']['job_name_3']['schedule']);
83 
84  $this->assertEmpty($result['default']['job_name_4']);
85  }
$source
Definition: source.php:23

◆ testConvertNoJobs()

testConvertNoJobs ( )

Testing not existed list of jobs

Definition at line 26 of file DbTest.php.

27  {
28  $source = [];
29  $result = $this->_converter->convert($source);
30  $this->assertEmpty($result);
31  }
$source
Definition: source.php:23

◆ testConvertRunConfig()

testConvertRunConfig ( )

Testing 'run' container

Definition at line 90 of file DbTest.php.

91  {
92  $runFullJob = ['run' => ['model' => 'Model1::method1']];
93  $runNoMethodJob = ['run' => ['model' => 'Model2']];
94  $runEmptyMethodJob = ['run' => ['model' => 'Model3::']];
95  $runNoModelJob = ['run' => ['model' => '::method1']];
96 
97  $source = [
98  'crontab' => [
99  'default' => [
100  'jobs' => [
101  'job_name_1' => $runFullJob,
102  'job_name_2' => $runNoMethodJob,
103  'job_name_3' => $runEmptyMethodJob,
104  'job_name_4' => $runNoModelJob,
105  ],
106  ],
107  ],
108  ];
109  $expected = [
110  'default' => [
111  'job_name_1' => ['instance' => 'Model1', 'method' => 'method1'],
112  'job_name_2' => [],
113  'job_name_3' => [],
114  'job_name_4' => [],
115  ],
116  ];
117  $result = $this->_converter->convert($source);
118  $this->assertEquals(
119  $expected['default']['job_name_1']['instance'],
120  $result['default']['job_name_1']['instance']
121  );
122  $this->assertEquals($expected['default']['job_name_1']['method'], $result['default']['job_name_1']['method']);
123 
124  $this->assertEmpty($result['default']['job_name_2']);
125  $this->assertEmpty($result['default']['job_name_3']);
126  $this->assertEmpty($result['default']['job_name_4']);
127  }
$source
Definition: source.php:23

Field Documentation

◆ $_converter

$_converter
protected

Definition at line 13 of file DbTest.php.


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