Skip to content

Commit

Permalink
Merge pull request #16690 from yiisoft/fix-tests
Browse files Browse the repository at this point in the history
Fixing travis
  • Loading branch information
samdark committed Sep 8, 2018
2 parents 2aa7986 + 8b3da74 commit 1b32a0f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
1 change: 0 additions & 1 deletion framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Yii Framework 2 Change Log
- Bug #16377: Fixed `yii\base\Event:off()` undefined index error when event handler does not match (razvanphp)
- Bug #16514: Fixed `yii\di\Container::resolveCallableDependencies` to support callable object (wi1dcard)
- Bug #15889: Fixed override `yii\helpers\Html::setActivePlaceholder` (lesha724)
- Bug #16552: Added check in `yii\db\ActiveQuery::prepare()` to prevent populating already populated relation when another relation is requested with `via` (drlibra)
- Enh #16522: Allow jQuery 3.3 (Slamdunk)
- Enh #16603: Added `yii\mutex\FileMutex::$isWindows` for Windows file shares on Unix guest machines (brandonkelly)
- Bug #16666: Fixed `yii\helpers\ArrayHelper::merge` (rustamwin)
Expand Down
4 changes: 1 addition & 3 deletions framework/assets/yii.validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ yii.validation = (function ($) {

trim: function ($form, attribute, options, value) {
var $input = $form.find(attribute.input);
var isCheckAble = $input.find('[type=radio]').is('[type=radio]') || $input.find('[type=checkbox]').is('[type=checkbox]');

if (!isCheckAble) {
if ($input.is(':checkbox, :radio')) {
return value;
}

Expand Down
16 changes: 4 additions & 12 deletions framework/db/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,11 @@ public function prepare($builder)
/* @var $viaQuery ActiveQuery */
list($viaName, $viaQuery) = $this->via;
if ($viaQuery->multiple) {
if ($this->primaryModel->isRelationPopulated($viaName)) {
$viaModels = $this->primaryModel->$viaName;
} else {
$viaModels = $viaQuery->all();
$this->primaryModel->populateRelation($viaName, $viaModels);
}
$viaModels = $viaQuery->all();
$this->primaryModel->populateRelation($viaName, $viaModels);
} else {
if ($this->primaryModel->isRelationPopulated($viaName)) {
$model = $this->primaryModel->$viaName;
} else {
$model = $viaQuery->one();
$this->primaryModel->populateRelation($viaName, $model);
}
$model = $viaQuery->one();
$this->primaryModel->populateRelation($viaName, $model);
$viaModels = $model === null ? [] : [$model];
}
$this->filterByModels($viaModels);
Expand Down
2 changes: 1 addition & 1 deletion framework/di/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public function resolveCallableDependencies(callable $callback, $params = [])
{
if (is_array($callback)) {
$reflection = new \ReflectionMethod($callback[0], $callback[1]);
} elseif (is_object($callback)) {
} elseif (is_object($callback) && !$callback instanceof \Closure) {
$reflection = new \ReflectionMethod($callback, '__invoke');
} else {
$reflection = new \ReflectionFunction($callback);
Expand Down
29 changes: 29 additions & 0 deletions tests/js/tests/yii.validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,9 @@ describe('yii.validation', function () {
var $input = {
val: function () {
return getInputVal();
},
is: function () {
return false;
}
};
var $form = {
Expand Down Expand Up @@ -1274,6 +1277,32 @@ describe('yii.validation', function () {
});
});

describe('trim filter on checkbox', function () {
var attribute = {input: '#input-id'};
var getInputVal;
var $checkbox = {
is: function (selector) {
if (selector === ':checked') {
return true;
}

if (selector === ':checkbox, :radio') {
return true;
}
}
};
var $form = {
find: function () {
return $checkbox;
}
};


it('should be left as is', function () {
assert.strictEqual(yii.validation.trim($form, attribute, {}, true), true);
});
});

describe('captcha validator', function () {
// Converted using yii\captcha\CaptchaAction generateValidationHash() method
var hashes = {'Code': 379, 'code': 411};
Expand Down

0 comments on commit 1b32a0f

Please sign in to comment.