1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DNADesign\Elemental\Tests\Legacy\GraphQL; |
4
|
|
|
|
5
|
|
|
use DNADesign\Elemental\GraphQL\SortBlockMutationCreator; |
6
|
|
|
use DNADesign\Elemental\Tests\Src\TestElement; |
7
|
|
|
use SilverStripe\GraphQL\Tests\Fake\FakeResolveInfo; |
|
|
|
|
8
|
|
|
use SilverStripe\Dev\SapphireTest; |
9
|
|
|
use SilverStripe\GraphQL\Schema\Schema; |
|
|
|
|
10
|
|
|
use SilverStripe\Security\Security; |
11
|
|
|
|
12
|
|
|
class SortBlockMutationCreatorTest extends SapphireTest |
13
|
|
|
{ |
14
|
|
|
protected static $fixture_file = 'SortBlockMutationCreatorTest.yml'; |
15
|
|
|
|
16
|
|
|
protected static $extra_dataobjects = [ |
17
|
|
|
TestElement::class, |
18
|
|
|
]; |
19
|
|
|
|
20
|
|
|
protected function setUp(): void |
21
|
|
|
{ |
22
|
|
|
parent::setUp(); |
23
|
|
|
if (class_exists(Schema::class)) { |
24
|
|
|
$this->markTestSkipped('Skipped GraphQL 3 test ' . __CLASS__); |
25
|
|
|
} |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Reorders blocks by compounding each result into the next test (rather than isolated sorting tests) |
30
|
|
|
*/ |
31
|
|
|
public function testSortBlock() |
32
|
|
|
{ |
33
|
|
|
$this->runMutation(1, 3); |
34
|
|
|
$this->assertIdsInOrder([2, 3, 1, 4]); |
35
|
|
|
|
36
|
|
|
$this->runMutation(4, 2); |
37
|
|
|
$this->assertIdsInOrder([2, 4, 3, 1]); |
38
|
|
|
|
39
|
|
|
$this->runMutation(1, 0); |
40
|
|
|
$this->assertIdsInOrder([1, 2, 4, 3]); |
41
|
|
|
|
42
|
|
|
$this->runMutation(3, 2); |
43
|
|
|
$this->assertIdsInOrder([1, 2, 3, 4]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
protected function assertIdsInOrder($ids) |
47
|
|
|
{ |
48
|
|
|
$actualIDs = TestElement::get()->sort('Sort')->map()->keys(); |
49
|
|
|
|
50
|
|
|
$this->assertSame($ids, $actualIDs); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
protected function runMutation($id, $afterBlockId) |
54
|
|
|
{ |
55
|
|
|
$member = Security::getCurrentUser(); |
56
|
|
|
|
57
|
|
|
$mutation = new SortBlockMutationCreator(); |
|
|
|
|
58
|
|
|
$context = ['currentUser' => $member]; |
59
|
|
|
$resolveInfo = new FakeResolveInfo([]); |
60
|
|
|
|
61
|
|
|
$mutation->resolve(null, [ |
62
|
|
|
'id' => $id, |
63
|
|
|
'afterBlockID' => $afterBlockId, |
64
|
|
|
], $context, $resolveInfo); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths