PHP code example of developeruz / yii-matcher
1. Go to this page and download the library: Download developeruz/yii-matcher library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
developeruz / yii-matcher example snippets
use developeruz\yii_matcher\ModelMatcher;
class ValidateTest extends TestCase {
public function testPhoneIsSafeOnlyInRegistration()
{
$userModel = new ModelMatcher('app\models\User');
$userModel->shouldBeSafe('phone', 'registration');
$userModel->shouldBeNotSafe('phone');
}
public function testUserHasPostsRelation()
{
$userModel = new ModelMatcher('app\models\User');
$userModel->hasMany('posts', 'app\models\Post', ['user_id' => 'id']);
}
public function testLoginLength()
{
$userModel = new ModelMatcher('app\models\User');
$userModel->matchLength('login', 3, 20);
}
}
bash
$ php composer.phar