Browse Source

Improved ValidatorTest organization.

tags/2.0.0-beta
Suralc 12 years ago
parent
commit
a81480d309
  1. 21
      tests/unit/data/validators/models/FakedValidationModel.php
  2. 3
      tests/unit/framework/validators/BooleanValidatorTest.php
  3. 2
      tests/unit/framework/validators/CompareValidatorTest.php
  4. 2
      tests/unit/framework/validators/DateValidatorTest.php
  5. 1
      tests/unit/framework/validators/EmailValidatorTest.php
  6. 1
      tests/unit/framework/validators/NumberValidatorTest.php
  7. 1
      tests/unit/framework/validators/StringValidatorTest.php
  8. 3
      tests/unit/framework/validators/UrlValidatorTest.php

21
tests/unit/framework/validators/FakedValidationModel.php → tests/unit/data/validators/models/FakedValidationModel.php

@ -1,6 +1,6 @@
<?php <?php
namespace yiiunit\framework\validators; namespace yiiunit\data\validators\models;
use yii\base\Model; use yii\base\Model;
@ -11,6 +11,25 @@ class FakedValidationModel extends Model
{ {
private $attr = array(); private $attr = array();
public $val_attr_a;
public $val_attr_b;
public $val_attr_c;
public $val_attr_d;
public function rules()
{
return array(
array('val_attr_a, val_attr_b', 'required', 'on' => 'reqTest'),
array('val_attr_c', 'integer'),
);
}
public function inlineVal($attribute, $params = array())
{
return true;
}
public function __get($name) public function __get($name)
{ {
if (stripos($name, 'attr') === 0) { if (stripos($name, 'attr') === 0) {

3
tests/unit/framework/validators/BooleanValidatorTest.php

@ -1,11 +1,10 @@
<?php <?php
namespace yiiunit\framework\validators; namespace yiiunit\framework\validators;
use yiiunit\framework\validators\FakedValidationModel; use yiiunit\data\validators\models\FakedValidationModel;
use yii\validators\BooleanValidator; use yii\validators\BooleanValidator;
use yiiunit\TestCase; use yiiunit\TestCase;
require_once __DIR__ . '/FakedValidationModel.php';
/** /**
* BooleanValidatorTest * BooleanValidatorTest
*/ */

2
tests/unit/framework/validators/CompareValidatorTest.php

@ -3,9 +3,9 @@ namespace yiiunit\framework\validators;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\validators\CompareValidator; use yii\validators\CompareValidator;
use yiiunit\data\validators\models\FakedValidationModel;
use yiiunit\TestCase; use yiiunit\TestCase;
require_once __DIR__ . '/FakedValidationModel.php';
class CompareValidatorTest extends TestCase class CompareValidatorTest extends TestCase

2
tests/unit/framework/validators/DateValidatorTest.php

@ -4,9 +4,9 @@ namespace yiiunit\framework\validators;
use DateTime; use DateTime;
use yii\validators\DateValidator; use yii\validators\DateValidator;
use yiiunit\data\validators\models\FakedValidationModel;
use yiiunit\TestCase; use yiiunit\TestCase;
require_once __DIR__ . '/FakedValidationModel.php';
class DateValidatorTest extends TestCase class DateValidatorTest extends TestCase
{ {

1
tests/unit/framework/validators/EmailValidatorTest.php

@ -2,6 +2,7 @@
namespace yiiunit\framework\validators; namespace yiiunit\framework\validators;
use yii\validators\EmailValidator; use yii\validators\EmailValidator;
use yiiunit\data\validators\models\FakedValidationModel;
use yiiunit\TestCase; use yiiunit\TestCase;
/** /**

1
tests/unit/framework/validators/NumberValidatorTest.php

@ -4,6 +4,7 @@ namespace yiiunit\framework\validators;
use yii\validators\NumberValidator; use yii\validators\NumberValidator;
use yiiunit\data\validators\models\FakedValidationModel;
use yiiunit\TestCase; use yiiunit\TestCase;
class NumberValidatorTest extends TestCase class NumberValidatorTest extends TestCase

1
tests/unit/framework/validators/StringValidatorTest.php

@ -4,6 +4,7 @@ namespace yiiunit\framework\validators;
use yii\validators\StringValidator; use yii\validators\StringValidator;
use yiiunit\data\validators\models\FakedValidationModel;
use yiiunit\TestCase; use yiiunit\TestCase;
class StringValidatorTest extends TestCase class StringValidatorTest extends TestCase

3
tests/unit/framework/validators/UrlValidatorTest.php

@ -1,10 +1,9 @@
<?php <?php
namespace yiiunit\framework\validators; namespace yiiunit\framework\validators;
use yiiunit\framework\validators\FakedValidationModel; use yiiunit\data\validators\models\FakedValidationModel;
use yii\validators\UrlValidator; use yii\validators\UrlValidator;
use yiiunit\TestCase; use yiiunit\TestCase;
require_once __DIR__ . '/FakedValidationModel.php';
/** /**
* UrlValidatorTest * UrlValidatorTest
*/ */

Loading…
Cancel
Save