12 public $fixtures = array(
20 Yii::app()->getModule(
'shoppingcart')->setImport(array(
'shoppingcart.controllers.*'));
26 $c = $this->getMock(
'ItemController', array(
'redirect'),array(
'phpunit'));
27 $c->expects($this->any())
29 $c->setAction(
new CInlineAction($c,
'urltest'));
30 Yii::app()->setController($c);
32 $am = $this->getMock(
'AssetsManager',
36 )->expects($this->any())
39 Yii::app()->setComponent(
'assetManager', array(
'class'=>
'MocAssetsManager'));
43 'title' =>
'Item name',
45 'admin_email' =>
'andrew_@mail.ru',
47 'class' =>
'shoppingcart_item',
48 'shoppingcart_link' =>
'/Content.Node/service/Shopping_Cart.en.html',
52 public function testItemWidget(){
54 $itemWidgetHtml = Yii::app()->controller->widget(
'shoppingcart.widgets.ItemWidget',
58 preg_match(
"/Item\[title\]/", $itemWidgetHtml, $match);
59 $this->assertNotEmpty($match,
"Title input does not exists");
60 preg_match(
"/Item\[price\]/", $itemWidgetHtml, $match);
61 $this->assertNotEmpty($match,
"Price input does not exists");
62 preg_match(
"/Item\[admin_email\]/", $itemWidgetHtml, $match);
63 $this->assertNotEmpty($match,
"Admin_email input does not exists");
64 preg_match(
"/Item\[item_id\]/", $itemWidgetHtml, $match);
65 $this->assertNotEmpty($match,
"Admin_email input does not exists");
66 preg_match(
"/Item\[page_id\]/", $itemWidgetHtml, $match);
67 $this->assertNotEmpty($match,
"Page_id input does not exists");
68 preg_match(
'/class="shoppingcart_item"/', $itemWidgetHtml, $match);
69 $this->assertNotEmpty($match,
"Class does not specified");
70 preg_match(
'/class="shoppingcart_item"/', $itemWidgetHtml, $match);
71 $this->assertNotEmpty($match,
"Class does not specified");
72 preg_match(
'/e117a4a93357557f72e437c0eae0c4e4/', $itemWidgetHtml, $match);
73 $this->assertNotEmpty($match,
"Checksum is wrong");
76 $item->setAttributes($this->data,
false);
86 'item_referrer' =>
'',
87 'shoppingcart_link' =>
'/Content.Node/service/Shopping_Cart.en.html',
89 'checksum' => $item->getItemChecksum(),
92 $_POST = $addItemPost;
95 'REMOTE_ADDR'=>
'127.0.0.1',
96 'HTTP_REFERER' =>
'/Content.Node/service/Shopping_Cart.en.html',
97 'REDIRECT_URL' =>
'REDIRECT_URL',
98 'REQUEST_URI' =>
'/Content.Node/service/Shopping_Cart.en.html',
99 'SCRIPT_FILENAME' =>
'index.php',
102 Yii::app()->controller->actionAdd();
104 $this->assertEquals(1, (
Item::model()->count()),
'The item was not added');
107 $itemListWidgetHtml = Yii::app()->controller->widget(
'common.modules.shoppingcart.widgets.ItemListWidget',
108 array(
'title'=>
'MY CART',
111 'shoppingcart_link'=>
'widgetsTests/shoppingcartCart',
112 'link_items_to_page' =>
true
116 preg_match(
"/".$this->data[
'title'].
"/", $itemListWidgetHtml, $match);
117 $this->assertNotEmpty($match,
"Added item is absent in the itemListWidget");
120 $steps = array(1,2,3,4);
121 foreach($steps as $step){
138 'salutation' =>
'mr',
139 'firstname' =>
'Andrew',
140 'lastname' =>
'Voloshin',
141 'birthday' =>
'Jan 1, 1970',
142 'company' =>
'oberig',
143 'street' =>
'street',
144 'zip_code' =>
'zipcode',
146 'country' =>
'Ukraine',
147 'telephone' =>
'0630202237',
148 'email' =>
'Andrew.Voloshin@mail.ru',
158 'shipping_info' =>
'Shipping_info',
159 'payment_info' =>
'Payment_info',
161 'checksum' => md5(
'Shipping_infoPayment_info'),
178 $_REQUEST[
'step'] = $step;
180 $shoppingCartWidgetHtml = Yii::app()->controller->widget(
'shoppingcart.widgets.ShoppingCartWidget',
182 'class'=>
'shoppingcart',
183 'shipping_info' =>
'some shipping info ...',
184 'payment_info' =>
'some payment info ...',
185 'layout' =>
'ShoppingCartWidget',
186 'link_items_to_page' =>
true
191 $this->assertEquals(1, (
Order::model()->count(
'ordered = :ordered', array(
':ordered' => 1))),
'The order was not added');