Skip to content

Commit 922a44d

Browse files
committed
Cleaned up test files from fully qualified names
1 parent 3088f39 commit 922a44d

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed

tests/Unit/DataLoaderAbuseTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use leinonen\DataLoader\DataLoader;
1010
use leinonen\DataLoader\DataLoaderException;
1111
use PHPUnit\Framework\TestCase;
12+
use function React\Promise\resolve;
1213

1314
class DataLoaderAbuseTest extends TestCase
1415
{
@@ -31,7 +32,7 @@ public function load_method_requires_an_actual_key()
3132
$this->expectExceptionMessage('leinonen\DataLoader\DataLoader::load must be called with a value, but got null');
3233

3334
$loader = $this->createDataLoader(function ($keys) {
34-
return \React\Promise\resolve($keys);
35+
return resolve($keys);
3536
});
3637
$loader->load(null);
3738
}
@@ -40,7 +41,7 @@ public function load_method_requires_an_actual_key()
4041
public function falsey_values_are_however_permitted()
4142
{
4243
$loader = $this->createDataLoader(function ($keys) {
43-
return \React\Promise\resolve($keys);
44+
return resolve($keys);
4445
});
4546
$this->assertInstanceOf(Promise::class, $loader->load(0));
4647
}
@@ -54,7 +55,7 @@ public function load_many_requires_actual_keys()
5455
$this->expectExceptionMessage('leinonen\DataLoader\DataLoader::load must be called with a value, but got null');
5556

5657
$loader = $this->createDataLoader(function ($keys) {
57-
return \React\Promise\resolve($keys);
58+
return resolve($keys);
5859
});
5960
$loader->loadMany([null, null]);
6061
}
@@ -161,7 +162,7 @@ function ($keys) {
161162
public function batch_function_must_return_a_promise_of_an_array_not_null()
162163
{
163164
$badLoader = $this->createDataLoader(function ($keys) {
164-
return \React\Promise\resolve();
165+
return resolve();
165166
});
166167

167168
$exception = null;
@@ -185,7 +186,7 @@ public function batch_function_must_return_a_promise_of_an_array_not_null()
185186
public function batch_function_must_promise_an_array_of_correct_length()
186187
{
187188
$emptyArrayLoader = $this->createDataLoader(function ($keys) {
188-
return \React\Promise\resolve([]);
189+
return resolve([]);
189190
});
190191

191192
$exception = null;

tests/Unit/DataLoaderTest.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
namespace leinonen\DataLoader\Tests\Unit;
44

55
use PHPUnit\Framework\TestCase;
6+
use function React\Promise\all;
67
use React\Promise\Promise;
78
use React\EventLoop\Factory;
89
use leinonen\DataLoader\CacheMap;
910
use React\EventLoop\LoopInterface;
1011
use leinonen\DataLoader\DataLoader;
1112
use leinonen\DataLoader\DataLoaderOptions;
13+
use function React\Promise\resolve;
1214

1315
class DataLoaderTest extends TestCase
1416
{
@@ -36,7 +38,7 @@ public function it_builds_a_really_simple_data_loader()
3638
{
3739
$identityLoader = new DataLoader(
3840
function ($keys) {
39-
return \React\Promise\resolve($keys);
41+
return resolve($keys);
4042
}, $this->eventLoop, new CacheMap()
4143
);
4244

@@ -94,7 +96,7 @@ public function it_batches_multiple_requests()
9496

9597
$values = [];
9698

97-
\React\Promise\all([$promise1, $promise2])->then(function ($returnedValues) use (&$values) {
99+
all([$promise1, $promise2])->then(function ($returnedValues) use (&$values) {
98100
$values = $returnedValues;
99101
});
100102

@@ -118,7 +120,7 @@ public function it_batches_multiple_requests_with_max_batch_sizes()
118120

119121
$values = [];
120122

121-
\React\Promise\all([$promise1, $promise2, $promise3])->then(function ($returnedValues) use (&$values) {
123+
all([$promise1, $promise2, $promise3])->then(function ($returnedValues) use (&$values) {
122124
$values = $returnedValues;
123125
});
124126

@@ -143,7 +145,7 @@ public function if_max_batch_size_is_set_to_0_it_still_batches_calls_normally()
143145

144146
$values = [];
145147

146-
\React\Promise\all([$promise1, $promise2, $promise3])->then(function ($returnedValues) use (&$values) {
148+
all([$promise1, $promise2, $promise3])->then(function ($returnedValues) use (&$values) {
147149
$values = $returnedValues;
148150
});
149151

@@ -168,7 +170,7 @@ public function it_coalesces_identical_requests()
168170

169171
$values = [];
170172

171-
\React\Promise\all([$promise1a, $promise1b])->then(function ($returnedValues) use (&$values) {
173+
all([$promise1a, $promise1b])->then(function ($returnedValues) use (&$values) {
172174
$values = $returnedValues;
173175
});
174176

@@ -188,7 +190,7 @@ public function it_caches_repeated_requests()
188190
$a = null;
189191
$b = null;
190192

191-
\React\Promise\all([
193+
all([
192194
$identityLoader->load('A'),
193195
$identityLoader->load('B'),
194196
])->then(function ($returnedValues) use (&$a, &$b) {
@@ -206,7 +208,7 @@ public function it_caches_repeated_requests()
206208
$a2 = null;
207209
$c = null;
208210

209-
\React\Promise\all([
211+
all([
210212
$identityLoader->load('A'),
211213
$identityLoader->load('C'),
212214
])->then(function ($returnedValues) use (&$a2, &$c) {
@@ -225,7 +227,7 @@ public function it_caches_repeated_requests()
225227
$b2 = null;
226228
$c2 = null;
227229

228-
\React\Promise\all([
230+
all([
229231
$identityLoader->load('A'),
230232
$identityLoader->load('B'),
231233
$identityLoader->load('C'),
@@ -252,7 +254,7 @@ public function it_can_clear_a_single_value_in_loader()
252254
$a = null;
253255
$b = null;
254256

255-
\React\Promise\all([
257+
all([
256258
$identityLoader->load('A'),
257259
$identityLoader->load('B'),
258260
])->then(function ($returnedValues) use (&$a, &$b) {
@@ -272,7 +274,7 @@ public function it_can_clear_a_single_value_in_loader()
272274
$a2 = null;
273275
$b2 = null;
274276

275-
\React\Promise\all([
277+
all([
276278
$identityLoader->load('A'),
277279
$identityLoader->load('B'),
278280
])->then(function ($returnedValues) use (&$a2, &$b2) {
@@ -296,7 +298,7 @@ public function it_can_clear_all_values_in_loader()
296298
$a = null;
297299
$b = null;
298300

299-
\React\Promise\all([
301+
all([
300302
$identityLoader->load('A'),
301303
$identityLoader->load('B'),
302304
])->then(function ($returnedValues) use (&$a, &$b) {
@@ -316,7 +318,7 @@ public function it_can_clear_all_values_in_loader()
316318
$a2 = null;
317319
$b2 = null;
318320

319-
\React\Promise\all([
321+
all([
320322
$identityLoader->load('A'),
321323
$identityLoader->load('B'),
322324
])->then(function ($returnedValues) use (&$a2, &$b2) {
@@ -342,7 +344,7 @@ public function it_can_prime_the_cache()
342344
$a = null;
343345
$b = null;
344346

345-
\React\Promise\all([
347+
all([
346348
$identityLoader->load('A'),
347349
$identityLoader->load('B'),
348350
])->then(function ($returnedValues) use (&$a, &$b) {
@@ -368,7 +370,7 @@ public function it_does_not_prime_keys_that_already_exist()
368370
$a1 = null;
369371
$b1 = null;
370372

371-
\React\Promise\all([
373+
all([
372374
$identityLoader->load('A'),
373375
$identityLoader->load('B'),
374376
])->then(function ($returnedValues) use (&$a1, &$b1) {
@@ -387,7 +389,7 @@ public function it_does_not_prime_keys_that_already_exist()
387389
$a2 = null;
388390
$b2 = null;
389391

390-
\React\Promise\all([
392+
all([
391393
$identityLoader->load('A'),
392394
$identityLoader->load('B'),
393395
])->then(function ($returnedValues) use (&$a2, &$b2) {
@@ -413,7 +415,7 @@ public function it_allows_forcefully_priming_the_cache()
413415
$a1 = null;
414416
$b1 = null;
415417

416-
\React\Promise\all([
418+
all([
417419
$identityLoader->load('A'),
418420
$identityLoader->load('B'),
419421
])->then(function ($returnedValues) use (&$a1, &$b1) {
@@ -434,7 +436,7 @@ public function it_allows_forcefully_priming_the_cache()
434436
$a2 = null;
435437
$b2 = null;
436438

437-
\React\Promise\all([
439+
all([
438440
$identityLoader->load('A'),
439441
$identityLoader->load('B'),
440442
])->then(function ($returnedValues) use (&$a2, &$b2) {
@@ -642,7 +644,7 @@ public function it_accepts_objects_as_keys()
642644
$valueA = null;
643645
$valueB = null;
644646

645-
\React\Promise\all([
647+
all([
646648
$identityLoader->load($keyA),
647649
$identityLoader->load($keyB),
648650
])->then(function ($returnedValues) use (&$valueA, &$valueB) {
@@ -665,7 +667,7 @@ public function it_accepts_objects_as_keys()
665667
$valueA = null;
666668
$valueB = null;
667669

668-
\React\Promise\all([
670+
all([
669671
$identityLoader->load($keyA),
670672
$identityLoader->load($keyB),
671673
])->then(function ($returnedValues) use (&$valueA, &$valueB) {
@@ -689,7 +691,7 @@ public function it_may_disable_batching()
689691
$a = null;
690692
$b = null;
691693

692-
\React\Promise\all([
694+
all([
693695
$identityLoader->load(1),
694696
$identityLoader->load(2),
695697
])->then(function ($returnedValues) use (&$a, &$b) {
@@ -712,7 +714,7 @@ public function it_may_disable_caching()
712714
$a = null;
713715
$b = null;
714716

715-
\React\Promise\all([
717+
all([
716718
$identityLoader->load('A'),
717719
$identityLoader->load('B'),
718720
])->then(function ($returnedValues) use (&$a, &$b) {
@@ -730,7 +732,7 @@ public function it_may_disable_caching()
730732
$a2 = null;
731733
$c = null;
732734

733-
\React\Promise\all([
735+
all([
734736
$identityLoader->load('A'),
735737
$identityLoader->load('C'),
736738
])->then(function ($returnedValues) use (&$a2, &$c) {
@@ -749,7 +751,7 @@ public function it_may_disable_caching()
749751
$b2 = null;
750752
$c2 = null;
751753

752-
\React\Promise\all([
754+
all([
753755
$identityLoader->load('A'),
754756
$identityLoader->load('B'),
755757
$identityLoader->load('C'),
@@ -773,14 +775,14 @@ public function it_batches_loads_occurring_within_promises()
773775
{
774776
$identityLoader = $this->createIdentityLoader();
775777

776-
\React\Promise\all([
778+
all([
777779
$identityLoader->load('A'),
778-
\React\Promise\resolve()->then(function () use ($identityLoader) {
779-
\React\Promise\resolve()->then(function () use ($identityLoader) {
780+
resolve()->then(function () use ($identityLoader) {
781+
resolve()->then(function () use ($identityLoader) {
780782
$identityLoader->load('B');
781-
\React\Promise\resolve()->then(function () use ($identityLoader) {
783+
resolve()->then(function () use ($identityLoader) {
782784
$identityLoader->load('C');
783-
\React\Promise\resolve()->then(function () use ($identityLoader) {
785+
resolve()->then(function () use ($identityLoader) {
784786
$identityLoader->load('D');
785787
});
786788
});
@@ -801,7 +803,7 @@ public function it_can_call_a_loader_from_a_loader()
801803
function ($keys) use (&$deepLoadCalls) {
802804
$deepLoadCalls[] = $keys;
803805

804-
return \React\Promise\resolve($keys);
806+
return resolve($keys);
805807
}, $this->eventLoop, new CacheMap()
806808
);
807809

@@ -828,7 +830,7 @@ function ($keys) use (&$bLoadCalls, $deepLoader) {
828830
$b1 = null;
829831
$b2 = null;
830832

831-
\React\Promise\all([
833+
all([
832834
$aLoader->load('A1'),
833835
$bLoader->load('B1'),
834836
$aLoader->load('A2'),
@@ -865,7 +867,7 @@ private function createIdentityLoader($options = null)
865867
function ($keys) {
866868
$this->loadCalls[] = $keys;
867869

868-
return \React\Promise\resolve($keys);
870+
return resolve($keys);
869871
}, $this->eventLoop, new CacheMap(), $options
870872
);
871873

@@ -885,7 +887,7 @@ private function createEvenLoader($options = null)
885887
function ($keys) {
886888
$this->loadCalls[] = $keys;
887889

888-
return \React\Promise\resolve(
890+
return resolve(
889891
array_map(
890892
function ($key) {
891893
if ($key % 2 === 0) {
@@ -914,7 +916,7 @@ private function createExceptionLoader()
914916
function ($keys) {
915917
$this->loadCalls[] = $keys;
916918

917-
return \React\Promise\resolve(
919+
return resolve(
918920
array_map(
919921
function ($key) {
920922
return new \Exception("Error: {$key}");

0 commit comments

Comments
 (0)