Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit 0f15ab7

Browse files
author
VladimirBerdnik
committed
Improve database IN and NOT IN rules tests
1 parent 00337fe commit 0f15ab7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/RuleSet.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ protected function appendIfNotExists($rule)
9090
{
9191
if (in_array($rule, $this->rules)) {
9292
return $this;
93-
}
94-
else {
93+
} else {
9594
return new static(array_merge($this->rules, [$rule]));
9695
}
9796
}
@@ -108,16 +107,15 @@ protected static function mergeIfNotExists(string $rule, array $rules = []): arr
108107
{
109108
if (in_array($rule, $rules)) {
110109
return $rules;
111-
}
112-
else {
110+
} else {
113111
return array_merge($rules, [$rule]);
114112
}
115113
}
116114

117115
/** Return current rule set as array */
118116
public function toArray(): array
119117
{
120-
return array_map(function($rule) {
118+
return array_map(function ($rule) {
121119
if ($rule instanceof IRule) {
122120
return (string)$rule;
123121
} else {

tests/RuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ public function testSometimes()
6464
*/
6565
public function testIn()
6666
{
67-
$this->assertEquals('in:male,female', Rule::in('male', 'female'));
68-
$this->assertEquals('in:Male,Female', Rule::in(Gender::getConstants()));
67+
$this->assertEquals('in:"male","female"', Rule::in('male', 'female'));
68+
$this->assertEquals('in:"Male","Female"', Rule::in(Gender::getConstants()));
6969
}
7070

7171
/**
7272
* Rule 'notIn' can accept values as list of parameters or as array
7373
*/
7474
public function testNotIn()
7575
{
76-
$this->assertEquals('not_in:forbidden,deleted', Rule::notIn('forbidden', 'deleted'));
77-
$this->assertEquals('not_in:forbidden,deleted', Rule::notIn(['forbidden', 'deleted']));
76+
$this->assertEquals('not_in:"forbidden","deleted"', Rule::notIn('forbidden', 'deleted'));
77+
$this->assertEquals('not_in:"forbidden","deleted"', Rule::notIn(['forbidden', 'deleted']));
7878
}
7979

8080
/**

0 commit comments

Comments
 (0)