|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace tests; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
use tests\models\Category; |
|
7
|
|
|
use corpsepk\yml\models\Shop; |
|
8
|
|
|
use corpsepk\yml\models\Offer; |
|
9
|
|
|
use corpsepk\yml\YandexMarketYml; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* BuildYmlTest |
|
13
|
|
|
*/ |
|
14
|
|
|
class YandexMarketYmlModuleTest extends \PHPUnit_Framework_TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
public function testBuildYml() |
|
17
|
|
|
{ |
|
18
|
|
|
Yii::$app->setModule('YandexMarketYml', [ |
|
19
|
|
|
'class' => YandexMarketYml::className(), |
|
20
|
|
|
'cacheProvider' => new \yii\caching\DummyCache(), |
|
21
|
|
|
]); |
|
22
|
|
|
|
|
23
|
|
|
/** @var YandexMarketYml $module */ |
|
24
|
|
|
$module = Yii::$app->getModule('YandexMarketYml'); |
|
25
|
|
|
$actual = $module->createControllerByID('default')->renderPartial('index', [ |
|
26
|
|
|
'shop' => new Shop([ |
|
27
|
|
|
'name' => 'MyCompanyName', |
|
28
|
|
|
'company' => 'LTD MyCompanyName', |
|
29
|
|
|
'url' => 'http://example.com', |
|
30
|
|
|
'currencies' => [ |
|
31
|
|
|
['id' => 'RUR', 'rate' => 1] |
|
32
|
|
|
], |
|
33
|
|
|
'categories' => [ |
|
34
|
|
|
new Category([ |
|
35
|
|
|
'id' => 1, |
|
36
|
|
|
'name' => 'First Category', |
|
37
|
|
|
'parentId' => null, |
|
38
|
|
|
]), |
|
39
|
|
|
], |
|
40
|
|
|
'offers' => [ |
|
41
|
|
|
new Offer([ |
|
42
|
|
|
'id' => 1, |
|
43
|
|
|
'available' => true, |
|
44
|
|
|
'url' => 'http://example.com/item/1', |
|
45
|
|
|
'price' => 1560, |
|
46
|
|
|
'currencyId' => 'RUR', |
|
47
|
|
|
'categoryId' => 1, |
|
48
|
|
|
'picture' => 'http://example.com/images/1.jpg', |
|
49
|
|
|
'name' => 'Jacket', |
|
50
|
|
|
'vendor' => 'Manufacturer', |
|
51
|
|
|
'description' => 'Item description', |
|
52
|
|
|
]), |
|
53
|
|
|
new Offer([ |
|
54
|
|
|
'id' => 2, |
|
55
|
|
|
'available' => false, |
|
56
|
|
|
'url' => 'http://example.com/item/2', |
|
57
|
|
|
'price' => 2360, |
|
58
|
|
|
'currencyId' => 'RUR', |
|
59
|
|
|
'categoryId' => 1, |
|
60
|
|
|
'picture' => 'http://example.com/images/2.jpg', |
|
61
|
|
|
'name' => 'T-shirt', |
|
62
|
|
|
'vendor' => 'Manufacturer', |
|
63
|
|
|
'description' => 'Items description', |
|
64
|
|
|
]), |
|
65
|
|
|
] |
|
66
|
|
|
]), |
|
67
|
|
|
]); |
|
68
|
|
|
$expected = file_get_contents(__DIR__ . '/data/yml.bin'); |
|
69
|
|
|
$this->assertEquals($expected, $actual); |
|
70
|
|
|
} |
|
71
|
|
|
} |