@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | defined('YII_DEBUG') or define('YII_DEBUG', true); |
3 | 3 | defined('YII_ENV') or define('YII_ENV', 'test'); |
4 | -require(__DIR__ . '/../vendor/autoload.php'); |
|
5 | -require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); |
|
4 | +require(__DIR__.'/../vendor/autoload.php'); |
|
5 | +require(__DIR__.'/../vendor/yiisoft/yii2/Yii.php'); |
|
6 | 6 | |
7 | 7 | Yii::setAlias('@tests', __DIR__); |
8 | 8 |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | public function rules() |
480 | 480 | { |
481 | 481 | return [ |
482 | - ['id', function () { |
|
483 | - $this->id = (string)$this->id; |
|
482 | + ['id', function() { |
|
483 | + $this->id = (string) $this->id; |
|
484 | 484 | return true; |
485 | 485 | }], |
486 | 486 | ['id', 'required'], |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | ['categoryId', 'required'], |
495 | 495 | ['categoryId', 'number', 'min' => 1], |
496 | - ['categoryId', function () { |
|
496 | + ['categoryId', function() { |
|
497 | 497 | if (strlen($this->categoryId) > 18) { |
498 | 498 | return false; |
499 | 499 | }; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | ['oldprice', 'safe'], |
523 | 523 | // В <oldprice> указывается старая цена товара, которая должна быть обязательно выше новой цены (<price>). |
524 | 524 | // Скидка может показываться в процентах. |
525 | - ['oldprice', 'compare', 'compareAttribute' => 'price', 'operator' => '>', 'type' => 'number', 'when' => function ($model) { |
|
525 | + ['oldprice', 'compare', 'compareAttribute' => 'price', 'operator' => '>', 'type' => 'number', 'when' => function($model) { |
|
526 | 526 | /** @var $model self */ |
527 | 527 | return strpos($this->oldprice, '%') === false; |
528 | 528 | }], |
@@ -538,38 +538,38 @@ discard block |
||
538 | 538 | [['available', 'store', 'pickup', 'delivery', 'downloadable', 'adult', 'cpa'], 'boolean'], |
539 | 539 | // Булево должно быть преобразовано к строке "true"/"false" |
540 | 540 | // https://yandex.ru/support/partnermarket/elements/id-type-available.xml |
541 | - [['available', 'store', 'pickup', 'delivery', 'downloadable', 'adult', 'cpa'], function ($attribute) { |
|
541 | + [['available', 'store', 'pickup', 'delivery', 'downloadable', 'adult', 'cpa'], function($attribute) { |
|
542 | 542 | $this->$attribute = $this->$attribute ? 'true' : 'false'; |
543 | - }, 'when' => function ($model, $attribute) { |
|
543 | + }, 'when' => function($model, $attribute) { |
|
544 | 544 | /** @var $model self */ |
545 | 545 | return is_bool($model->$attribute); |
546 | 546 | }], |
547 | 547 | |
548 | 548 | ['barcode', 'safe'], |
549 | 549 | |
550 | - ['picture', 'string', 'max' => 512, 'when' => function ($model) { |
|
550 | + ['picture', 'string', 'max' => 512, 'when' => function($model) { |
|
551 | 551 | /** @var $model self */ |
552 | 552 | return is_string($model->picture); |
553 | 553 | }], |
554 | - ['picture', 'each', 'rule' => ['string', 'max' => 512], 'when' => function ($model) { |
|
554 | + ['picture', 'each', 'rule' => ['string', 'max' => 512], 'when' => function($model) { |
|
555 | 555 | /** @var $model self */ |
556 | 556 | return is_array($model->picture); |
557 | 557 | }], |
558 | - ['picture', function () { |
|
558 | + ['picture', function() { |
|
559 | 559 | if (count($this->picture) > 10) { |
560 | - $this->addError('Offer can contain maximum 10 pictures, ' . count($this->picture) . ' included'); |
|
560 | + $this->addError('Offer can contain maximum 10 pictures, '.count($this->picture).' included'); |
|
561 | 561 | return false; |
562 | 562 | } |
563 | 563 | return true; |
564 | - }, 'when' => function ($model) { |
|
564 | + }, 'when' => function($model) { |
|
565 | 565 | /** @var self $model */ |
566 | 566 | return is_array($model->picture); |
567 | 567 | }], |
568 | 568 | |
569 | - ['rec', function () { |
|
569 | + ['rec', function() { |
|
570 | 570 | $this->rec = implode(',', $this->rec); |
571 | 571 | return true; |
572 | - }, 'when' => function ($model) { |
|
572 | + }, 'when' => function($model) { |
|
573 | 573 | /** @var self $model */ |
574 | 574 | return is_array($model->rec); |
575 | 575 | }], |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | } |
588 | 588 | } |
589 | 589 | return true; |
590 | - }, 'when' => function ($model) { |
|
590 | + }, 'when' => function($model) { |
|
591 | 591 | return !empty($model); |
592 | 592 | }] |
593 | 593 | ]; |