GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 7d8259...93df27 )
by Alexsandr
02:41
created

OfferModelTest   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 346
Duplicated Lines 29.77 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 17
lcom 1
cbo 3
dl 103
loc 346
rs 10
c 1
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidateId() 0 21 1
A testValidateUrl() 16 16 1
A testValidatePrice() 0 8 1
B testValidateOldPrice() 0 28 1
A testValidateCurrencyId() 0 16 2
B testValidateCategoryId() 6 36 3
B testValidatePicture() 0 29 1
A testValidateLocalDeliveryCost() 16 16 1
A testValidateVendor() 17 17 1
A testValidateVendorCode() 16 16 1
A testValidateDescription() 0 10 1
A testValidateSaleNotes() 16 16 1
A testValidateBarcode() 16 16 1
B testValidateParam() 0 25 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace tests;
3
4
use corpsepk\yml\models\Offer;
5
use yii\base\Security;
6
7
/**
8
 * OfferModelTest
9
 */
10
class OfferModelTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testValidateId()
13
    {
14
        $model = new Offer();
15
16
        // Обязательный атрибут
17
        $model->id = null;
18
        $this->assertFalse($model->validate(['id']));
19
20
        $model->id = '123';
21
        $this->assertTrue($model->validate(['id']));
22
23
        $model->id = 123;
1 ignored issue
show
Documentation Bug introduced by
The property $id was declared of type string, but 123 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
24
        $this->assertTrue($model->validate(['id']));
25
26
        $model->id = 'abc';
27
        $this->assertTrue($model->validate(['id']));
28
29
        // Максимальная длина - 20 символов
30
        $model->id = (new Security())->generateRandomString(21);
31
        $this->assertFalse($model->validate(['id']));
32
    }
33
34
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
35
//    public function testValidateType() {}
36
37
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
//    public function testValidateAvailable() {}
39
40
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
//    public function testValidateCBid() {}
42
43 View Code Duplication
    public function testValidateUrl()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        $model = new Offer();
46
47
        // Необязательный элемент для магазинов-салонов
48
        $model->url = null;
49
        $this->assertTrue($model->validate(['url']));
50
51
        // Максимальная длина - 512 символов
52
        $model->url = (new Security())->generateRandomString(10);
53
        $this->assertTrue($model->validate(['url']));
54
55
        // Максимальная длина - 512 символов
56
        $model->url = (new Security())->generateRandomString(513);
57
        $this->assertFalse($model->validate(['url']));
58
    }
59
60
    public function testValidatePrice()
61
    {
62
        $model = new Offer();
63
64
        // Обязательный элемент
65
        $model->price = null;
66
        $this->assertFalse($model->validate(['price']));
67
    }
68
69
    public function testValidateOldPrice()
70
    {
71
        $model = new Offer();
72
73
        // В <oldprice> указывается старая цена товара, которая должна быть обязательно выше новой цены (<price>)
74
        $model->price = null;
75
        $model->oldprice = 2;
1 ignored issue
show
Documentation Bug introduced by
The property $oldprice was declared of type string, but 2 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
76
        $this->assertFalse($model->validate(['price', 'oldprice']));
77
78
        // В <oldprice> указывается старая цена товара, которая должна быть обязательно выше новой цены (<price>)
79
        $model->price = 2;
1 ignored issue
show
Documentation Bug introduced by
The property $price was declared of type string, but 2 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
80
        $model->oldprice = 1;
1 ignored issue
show
Documentation Bug introduced by
The property $oldprice was declared of type string, but 1 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
81
        $this->assertFalse($model->validate(['oldprice']));
82
83
        // В <oldprice> указывается старая цена товара, которая должна быть обязательно выше новой цены (<price>)
84
        $model->price = 1;
1 ignored issue
show
Documentation Bug introduced by
The property $price was declared of type string, but 1 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
85
        $model->oldprice = 2;
86
        $this->assertTrue($model->validate(['oldprice']));
87
88
        // Скидка может показываться в процентах.
89
        $model->price = 20;
1 ignored issue
show
Documentation Bug introduced by
The property $price was declared of type string, but 20 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
90
        $model->oldprice = '10%';
91
        $this->assertTrue($model->validate(['oldprice']));
92
93
        $model->price = '20';
94
        $model->oldprice = '10%';
95
        $this->assertTrue($model->validate(['oldprice']));
96
    }
97
98
    public function testValidateCurrencyId()
99
    {
100
        $model = new Offer();
101
102
        foreach (Offer::CURRENCY_AVAILABLE as $currency)
103
        {
104
            $model->currencyId = $currency;
105
            $this->assertTrue($model->validate(['currencyId']));
106
        }
107
108
        $model->currencyId = 'NON';
109
        $this->assertFalse($model->validate(['currencyId']));
110
111
        $model->currencyId = null;
112
        $this->assertFalse($model->validate(['currencyId']));
113
    }
114
115
    public function testValidateCategoryId()
116
    {
117
        $model = new Offer();
118
119
        // Идентификатор категории товара (целое число не более 18 знаков)
120 View Code Duplication
        for ($i = 1; $i <= 18; $i++) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
121
            $model->categoryId .= rand(1, 9);
122
        }
123
        $this->assertTrue($model->validate(['categoryId']));
124
125
        // Идентификатор категории товара (целое число не более 18 знаков)
126 View Code Duplication
        for ($i = 1; $i <= 19; $i++) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
127
            $model->categoryId .= rand(1, 9);
128
        }
129
        $this->assertTrue($model->validate(['categoryId']));
130
131
        // Идентификатор категории товара (целое число не более 18 знаков)
132
        $model->categoryId = (new Security())->generateRandomKey(19);
133
        $this->assertFalse($model->validate(['categoryId']));
134
135
        // Элемент offer может содержать только один элемент categoryId
136
        $model->categoryId = [1, 2, 3];
1 ignored issue
show
Documentation Bug introduced by
It seems like array(1, 2, 3) of type array<integer,integer,{"...nteger","2":"integer"}> is incompatible with the declared type string of property $categoryId.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
137
        $this->assertFalse($model->validate(['categoryId']));
138
139
        // Идентификатор категории товара (целое число не более 18 знаков)
140
        $model->categoryId = 'abc';
141
        $this->assertFalse($model->validate(['categoryId']));
142
143
        // Идентификатор категории товара не может быть равен нулю
144
        $model->categoryId = 0;
1 ignored issue
show
Documentation Bug introduced by
The property $categoryId was declared of type string, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
145
        $this->assertFalse($model->validate(['categoryId']));
146
147
        // Идентификатор категории товара не может быть равен нулю
148
        $model->categoryId = '0';
149
        $this->assertFalse($model->validate(['categoryId']));
150
    }
151
152
    public function testValidatePicture()
153
    {
154
        $model = new Offer();
155
        $randomString20Symbols = (new Security())->generateRandomString(20);
156
        $randomString513Symbols = (new Security())->generateRandomString(513);
157
158
        $model->picture = null;
159
        $this->assertTrue($model->validate(['picture']));
160
161
        // Может быть строкой
162
        $model->picture = $randomString20Symbols;
163
        $this->assertTrue($model->validate(['picture']));
164
165
        // Может быть массивом
166
        $model->picture = [$randomString20Symbols, $randomString20Symbols];
167
        $this->assertTrue($model->validate(['picture']));
168
169
        // Максимальная длина URL — 512 символов
170
        $model->picture = $randomString513Symbols;
171
        $this->assertFalse($model->validate(['picture']));
172
173
        // Максимальная длина URL — 512 символов
174
        $model->picture = [$randomString513Symbols, $randomString20Symbols];
175
        $this->assertFalse($model->validate(['picture']));
176
177
        // Массив должен состоять не более чем из 10ти элементов
178
        $model->picture = array_fill(0, 11, $randomString20Symbols);
179
        $this->assertFalse($model->validate(['picture']));
180
    }
181
182
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
183
//    public function testValidateStore() {}
184
185
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
186
//    public function testValidatePickup() {}
187
188
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
189
//    public function testValidateDelivery() {}
190
191 View Code Duplication
    public function testValidateLocalDeliveryCost()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
192
    {
193
        $model = new Offer();
194
195
        $model->local_delivery_cost = null;
196
        $this->assertTrue($model->validate(['local_delivery_cost']));
197
198
        $model->local_delivery_cost = 100;
1 ignored issue
show
Documentation Bug introduced by
It seems like 100 of type integer is incompatible with the declared type string|null of property $local_delivery_cost.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
199
        $this->assertTrue($model->validate(['local_delivery_cost']));
200
201
        $model->local_delivery_cost = '100';
202
        $this->assertTrue($model->validate(['local_delivery_cost']));
203
204
        $model->local_delivery_cost = 'abc';
205
        $this->assertFalse($model->validate(['local_delivery_cost']));
206
    }
207
208
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
209
//    public function testValidateTypePrefix() {}
210
211
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
212
//    public function testValidateName() {}
213
214 View Code Duplication
    public function testValidateVendor()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
215
    {
216
        $model = new Offer();
217
218
        // Обязательный элемент
219
        $model->vendor = null;
220
        $this->assertFalse($model->validate(['vendor']));
221
222
        $model->vendor = '123abc';
223
        $this->assertTrue($model->validate(['vendor']));
224
225
        $model->vendor = 'abc';
226
        $this->assertTrue($model->validate(['vendor']));
227
228
        $model->vendor = 123;
1 ignored issue
show
Documentation Bug introduced by
The property $vendor was declared of type string, but 123 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
229
        $this->assertFalse($model->validate(['vendor']));
230
    }
231
232 View Code Duplication
    public function testValidateVendorCode()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
233
    {
234
        $model = new Offer();
235
236
        $model->vendorCode = null;
237
        $this->assertTrue($model->validate(['vendorCode']));
238
239
        $model->vendorCode = 123;
1 ignored issue
show
Documentation Bug introduced by
It seems like 123 of type integer is incompatible with the declared type string|null of property $vendorCode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
240
        $this->assertTrue($model->validate(['vendorCode']));
241
242
        $model->vendorCode = '123';
243
        $this->assertTrue($model->validate(['vendorCode']));
244
245
        $model->vendorCode = 'abc';
246
        $this->assertTrue($model->validate(['vendorCode']));
247
    }
248
249
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
250
//    public function testValidateModel() {}
251
252
    public function testValidateDescription()
253
    {
254
        $model = new Offer();
255
256
        $model->description = null;
257
        $this->assertTrue($model->validate(['description']));
258
259
        $model->description = (new Security())->generateRandomString(1000);
260
        $this->assertTrue($model->validate(['description']));
261
    }
262
263 View Code Duplication
    public function testValidateSaleNotes()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
264
    {
265
        $model = new Offer();
266
267
        // Необязательный элемент
268
        $model->sale_notes = null;
269
        $this->assertTrue($model->validate(['sale_notes']));
270
271
        // Допустимая длина текста в элементе — 50 символов
272
        $model->sale_notes = (new Security())->generateRandomString(50);
273
        $this->assertTrue($model->validate(['sale_notes']));
274
275
        // Допустимая длина текста в элементе — 50 символов
276
        $model->sale_notes = (new Security())->generateRandomString(51);
277
        $this->assertFalse($model->validate(['sale_notes']));
278
    }
279
280
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
281
//    public function testValidateManufacturerWarranty() {}
282
283
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
284
//    public function testValidateSellerWarranty() {}
285
286
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
287
//    public function testValidateCountryOfOrigin() {}
288
289
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
290
//    public function testValidateDownloadable() {}
291
292
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
293
//    public function testValidateAdult() {}
294
295
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
296
//    public function testValidateAge() {}
297
298 View Code Duplication
    public function testValidateBarcode()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
299
    {
300
        $model = new Offer();
301
302
        $model->barcode = null;
303
        $this->assertTrue($model->validate(['barcode']));
304
305
        $model->barcode = (new Security())->generateRandomString(20);
306
        $this->assertTrue($model->validate(['barcode']));
307
308
        $model->barcode = [
309
            (new Security())->generateRandomString(20),
310
            (new Security())->generateRandomString(20)
311
        ];
312
        $this->assertTrue($model->validate(['barcode']));
313
    }
314
315
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
316
//    public function testValidateCpa() {}
317
318
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
319
//    public function testValidateRec() {}
320
321
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
322
//    public function testValidateExpiry() {}
323
324
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
325
//    public function testValidateWeight() {}
326
327
    // TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
328
//    public function testValidateDimensions() {}
329
330
    public function testValidateParam()
331
    {
332
        $model = new Offer();
333
334
        $model->param = null;
335
        $this->assertTrue($model->validate(['param']));
336
337
        $model->param = [];
338
        $this->assertTrue($model->validate(['param']));
339
340
        $model->param = [
341
            ['name' => 'Размер', 'value' => '42-44'],
342
            ['name' => 'Цвет', 'value' => 'Красный']
343
        ];
344
        $this->assertTrue($model->validate(['param']));
345
346
        $model->param = ['Размер', '42-44'];
347
        $this->assertFalse($model->validate(['param']));
348
349
        $model->param = [
350
            ['name' => 'Размер', 'value' => '42-44'],
351
            ['name' => 'Цвет', 1 => 'Красный'],
352
        ];
353
        $this->assertFalse($model->validate(['param']));
354
    }
355
}
356