Skip to content

Commit 77c577a

Browse files
committed
Fix typo and move below other where methods
1 parent cbdfde2 commit 77c577a

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

src/Illuminate/Testing/Fluent/Concerns/Matching.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,6 @@
99

1010
trait Matching
1111
{
12-
/**
13-
* Assets that all values exist and match their expected values.
14-
*
15-
* @param string $key
16-
* @param array|string $expected
17-
*
18-
* @return $this
19-
*/
20-
public function whereHas(string $key, $expected)
21-
{
22-
$actual = Collection::make(
23-
$this->prop($key) ?? $this->prop()
24-
);
25-
26-
$missing = Collection::make($expected)->reject(function ($search) use ($key, $actual) {
27-
if ($actual->containsStrict($key, $search)) {
28-
return true;
29-
}
30-
31-
return $actual->containsStrict($search);
32-
})->toArray();
33-
34-
$values = array_values($missing);
35-
36-
PHPUnit::assertEmpty(
37-
$missing,
38-
sprintf(
39-
'Property [%s] does not contain [%s].',
40-
$key,
41-
implode(', ', $values)
42-
)
43-
);
44-
45-
return $this;
46-
}
47-
4812
/**
4913
* Asserts that the property matches the expected value.
5014
*
@@ -139,6 +103,42 @@ public function whereAllType(array $bindings): self
139103
return $this;
140104
}
141105

106+
/**
107+
* Asserts that all values exist and match their expected values.
108+
*
109+
* @param string $key
110+
* @param array|string $expected
111+
*
112+
* @return $this
113+
*/
114+
public function whereHas(string $key, $expected)
115+
{
116+
$actual = Collection::make(
117+
$this->prop($key) ?? $this->prop()
118+
);
119+
120+
$missing = Collection::make($expected)->reject(function ($search) use ($key, $actual) {
121+
if ($actual->containsStrict($key, $search)) {
122+
return true;
123+
}
124+
125+
return $actual->containsStrict($search);
126+
})->toArray();
127+
128+
$values = array_values($missing);
129+
130+
PHPUnit::assertEmpty(
131+
$missing,
132+
sprintf(
133+
'Property [%s] does not contain [%s].',
134+
$key,
135+
implode(', ', $values)
136+
)
137+
);
138+
139+
return $this;
140+
}
141+
142142
/**
143143
* Ensures that all properties are sorted the same way, recursively.
144144
*

0 commit comments

Comments
 (0)