1
+ <?php
2
+
3
+ namespace ProcessWire \GraphQL \Test \Field \Page \Fieldtype ;
4
+
5
+ /**
6
+ * Should properly handle FieldtypePage::derefAsPageArray option.
7
+ */
8
+ use \ProcessWire \GraphQL \Test \GraphQLTestCase ;
9
+ use ProcessWire \FieldtypePage ;
10
+ use ProcessWire \GraphQL \Utils ;
11
+
12
+ class FieldtypePageCaseFiveTest extends GraphQLTestCase {
13
+
14
+ const settings = [
15
+ 'login ' => 'admin ' ,
16
+ 'legalTemplates ' => ['skyscraper ' , 'architect ' , 'city ' ],
17
+ 'legalFields ' => ['architects ' , 'title ' ],
18
+ 'access ' => [
19
+ 'fields ' => [
20
+ [
21
+ 'name ' => 'architects ' ,
22
+ 'derefAsPage ' => FieldtypePage::derefAsPageOrNullPage,
23
+ ]
24
+ ]
25
+ ]
26
+ ];
27
+
28
+ public function testValue ()
29
+ {
30
+ $ architect = Utils::pages ()->get (4476 );
31
+ $ query = 'mutation createSkyscraper($page: SkyscraperCreateInput!){
32
+ createSkyscraper (page: $page) {
33
+ title,
34
+ name,
35
+ architects {
36
+ list {
37
+ id,
38
+ }
39
+ }
40
+ }
41
+ } ' ;
42
+ $ name = 'new-sky-test-158 ' ;
43
+ $ title = 'New Sky Test 158 ' ;
44
+ $ variables = [
45
+ 'page ' => [
46
+ 'name ' => $ name ,
47
+ 'title ' => $ title ,
48
+ 'parent ' => "4114 " ,
49
+ 'architects ' => [
50
+ 'add ' => [$ architect ->id ]
51
+ ]
52
+ ]
53
+ ];
54
+ $ res = self ::execute ($ query , $ variables );
55
+ $ actual = $ res ->data ->createSkyscraper ;
56
+ assertEquals ($ name , $ actual ->name , 'Sets the correct name. ' );
57
+ assertEquals ($ title , $ actual ->title , 'Sets the correct title. ' );
58
+ assertEquals ($ architect ->id , $ actual ->architects ->list [0 ]->id , 'Sets the correct architect. ' );
59
+ }
60
+ }
0 commit comments