10 Yii::import(
'shoppingcart.models');
15 public $items = array();
16 public $orders = array();
17 public $tmp_users = array();
19 public function testToCart()
21 echo
"<h3>Correct data test</h3>";
25 foreach($this->getItems(
true) as $set){
28 $item->setAttributes($set,
false);
31 $this->assertTrue($item->save());
33 }
catch (Exception $e){
34 echo $e->getMessage().
"<br/>";
39 echo
"<h3>".$counter.
" tests completed: ".$success.
" - success, ".$error.
" - error</h3>";
41 echo
"<h3>Incorrect data test</h3>";
45 foreach($this->getItems() as $set){
48 $item->setAttributes($set,
false);
51 $this->assertFalse($item->save());
53 }
catch (Exception $e){
54 echo $e->getMessage().
"<br/>";
59 echo
"<h3>".$counter.
" tests completed: ".$success.
" - success, ".$error.
" - error</h3>";
61 public function testTmpUser()
63 echo
"<h3>Correct data test</h3>";
67 foreach($this->getTmpUsers(
true) as $set){
70 $item->setAttributes($set,
false);
73 $this->assertTrue($item->save());
75 }
catch (Exception $e){
76 echo $e->getMessage().
"<br/>";
81 echo
"<h3>".$counter.
" tests completed: ".$success.
" - success, ".$error.
" - error</h3>";
84 echo
"<h3>Incorrect data test</h3>";
89 foreach($this->getTmpUsers() as $set){
92 $item->setAttributes($set,
false);
95 $this->assertFalse($item->save());
97 }
catch (Exception $e){
98 echo $e->getMessage().
"<br/>";
103 echo
"<h3>".$counter.
" tests completed: ".$success.
" - success, ".$error.
" - error</h3>";
106 public function getItems($correct =
false){
109 for($i = 1;$i<501; $i++)
111 'price' => rand(0,$i),
112 'admin_email' => substr(md5(uniqid(rand(),
true)),0,30).
'@'.substr(md5(uniqid(rand(),
true)),0,5).
'.com',
113 'page_id' => rand(0,$i),
114 'title' => substr(md5(uniqid(rand(),
true)),0,30),
115 'item_id' => rand(0,$i),
116 'order_id' => rand(0,$i),
117 'quantity' => rand(0,$i),
118 'referrer' => substr(md5(uniqid(rand(),
true)),0,50),
119 'ip_address' => rand(0,255).
'.'.rand(0,255).
'.'.rand(0,255).
'.'.rand(0,255),
123 for($i = 1;$i<250; $i++)
125 'price' => rand(-1,-$i-10),
126 'admin_email' => substr(md5(uniqid(rand(),
true)),0,30).
'@'.substr(md5(uniqid(rand(),
true)),0,5).
'.'.substr(md5(uniqid(rand(),
true)),0,3),
127 'page_id' => rand(0,$i),
128 'title' => substr(md5(uniqid(rand(),
true)),0,30),
129 'item_id' => rand(0,$i),
130 'order_id' => rand(0,$i),
131 'quantity' => rand(0,$i),
132 'referrer' => substr(md5(uniqid(rand(),
true)),0,50),
133 'ip_address' => rand(0,255).
'.'.rand(0,255).
'.'.rand(0,255).
'.'.rand(0,255),
135 for($i = 1;$i<252; $i++)
137 'price' => rand(0,$i),
138 'admin_email' => substr(md5(uniqid(rand(),
true)),0,30).
'@'.substr(md5(uniqid(rand(),
true)),0,5).
'.'.substr(md5(uniqid(rand(),
true)),0,3),
139 'page_id' => rand(0,$i),
140 'title' => substr(md5(uniqid(rand(),
true)),0,30),
141 'item_id' => rand(0,$i),
142 'order_id' => rand(0,$i),
143 'quantity' => rand(-1,-$i-10),
144 'referrer' => substr(md5(uniqid(rand(),
true)),0,50),
145 'ip_address' => rand(0,255).
'.'.rand(0,255).
'.'.rand(0,255).
'.'.rand(0,255),
152 public function getTmpUsers($correct =
false){
154 $format = Yii::app()->locale->getDateFormat();
157 for($i = 1;$i<51; $i++){
160 'salutation' => substr(md5(uniqid(rand(),
true)),0,3),
161 'firstname' => substr(md5(uniqid(rand(),
true)),0,12),
162 'lastname' => substr(md5(uniqid(rand(),
true)),0,12),
163 'company' => substr(md5(uniqid(rand(),
true)),0,12),
164 'birthday' => Yii::app()->dateFormatter->format($format, date(
'Y-m-d',time())),
165 'street' => substr(md5(uniqid(rand(),
true)),0,12),
166 'zip_code' => substr(md5(uniqid(rand(),
true)),0,12),
167 'city' => substr(md5(uniqid(rand(),
true)),0,12),
168 'country' => substr(md5(uniqid(rand(),
true)),0,12),
169 'telephone' => substr(md5(uniqid(rand(),
true)),0,12),
170 'email' => substr(md5(uniqid(rand(),
true)),0,6).
'@'.substr(md5(uniqid(rand(),
true)),0,4).
'.'.substr(md5(uniqid(rand(),
true)),0,3),
175 for($i = 1;$i<11; $i++){
178 'salutation' => substr(md5(uniqid(rand(),
true)),0,3),
179 'firstname' => substr(md5(uniqid(rand(),
true)),0,12),
180 'lastname' => substr(md5(uniqid(rand(),
true)),0,12),
181 'company' => substr(md5(uniqid(rand(),
true)),0,12),
182 'birthday' => Yii::app()->dateFormatter->format($format, date(
'Y-m-d',time())),
183 'street' => substr(md5(uniqid(rand(),
true)),0,12),
184 'zip_code' => substr(md5(uniqid(rand(),
true)),0,12),
185 'city' => substr(md5(uniqid(rand(),
true)),0,12),
186 'country' => substr(md5(uniqid(rand(),
true)),0,12),
187 'telephone' => substr(md5(uniqid(rand(),
true)),0,12),
188 'email' => substr(md5(uniqid(rand(),
true)),0,6).
'@'.substr(md5(uniqid(rand(),
true)),0,4),
191 for($i = 1;$i<11; $i++){
194 'salutation' => substr(md5(uniqid(rand(),
true)),0,3),
196 'lastname' => substr(md5(uniqid(rand(),
true)),0,12),
197 'company' => substr(md5(uniqid(rand(),
true)),0,12),
198 'birthday' => Yii::app()->dateFormatter->format($format, date(
'Y-m-d',time())),
199 'street' => substr(md5(uniqid(rand(),
true)),0,12),
200 'zip_code' => substr(md5(uniqid(rand(),
true)),0,12),
201 'city' => substr(md5(uniqid(rand(),
true)),0,12),
202 'country' => substr(md5(uniqid(rand(),
true)),0,12),
203 'telephone' => substr(md5(uniqid(rand(),
true)),0,12),
204 'email' => substr(md5(uniqid(rand(),
true)),0,6).
'@'.substr(md5(uniqid(rand(),
true)),0,4).
'.ru',
207 for($i = 1;$i<11; $i++){
210 'salutation' => substr(md5(uniqid(rand(),
true)),0,3),
211 'firstname' => substr(md5(uniqid(rand(),
true)),0,12),
213 'company' => substr(md5(uniqid(rand(),
true)),0,12),
214 'birthday' => Yii::app()->dateFormatter->format($format, date(
'Y-m-d',time())),
215 'street' => substr(md5(uniqid(rand(),
true)),0,12),
216 'zip_code' => substr(md5(uniqid(rand(),
true)),0,12),
217 'city' => substr(md5(uniqid(rand(),
true)),0,12),
218 'country' => substr(md5(uniqid(rand(),
true)),0,12),
219 'telephone' => substr(md5(uniqid(rand(),
true)),0,12),
220 'email' => substr(md5(uniqid(rand(),
true)),0,6).
'@'.substr(md5(uniqid(rand(),
true)),0,4).
'.'.substr(md5(uniqid(rand(),
true)),0,3),
223 for($i = 1;$i<21; $i++){
226 'salutation' => substr(md5(uniqid(rand(),
true)),0,3),
227 'firstname' => substr(md5(uniqid(rand(),
true)),0,12),
228 'lastname' => substr(md5(uniqid(rand(),
true)),0,12),
229 'company' => substr(md5(uniqid(rand(),
true)),0,12),
230 'birthday' => date(
'Y-m-d',time()),
231 'street' => substr(md5(uniqid(rand(),
true)),0,12),
232 'zip_code' => substr(md5(uniqid(rand(),
true)),0,12),
233 'city' => substr(md5(uniqid(rand(),
true)),0,12),
234 'country' => substr(md5(uniqid(rand(),
true)),0,12),
235 'telephone' => substr(md5(uniqid(rand(),
true)),0,12),
236 'email' => substr(md5(uniqid(rand(),
true)),0,6).
'@'.substr(md5(uniqid(rand(),
true)),0,4).
'.ru',