11<?php
2+
3+ /**
4+ * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5+ * @license For full copyright and license information view LICENSE file distributed with this source code.
6+ */
27namespace spec \EzSystems \EzPlatformGraphQL \Schema \Domain \Content ;
38
4- use eZ \Publish \Core \Repository \Values \ContentType \FieldDefinitionCollection ;
59use spec \EzSystems \EzPlatformGraphQL \Tools \TypeArgument ;
610use eZ \Publish \API \Repository \ContentTypeService ;
711use eZ \Publish \Core \Repository \Values \ContentType \ContentType ;
812use eZ \Publish \Core \Repository \Values \ContentType \ContentTypeGroup ;
913use eZ \Publish \Core \Repository \Values \ContentType \FieldDefinition ;
14+ use eZ \Publish \Core \Repository \Values \ContentType \FieldDefinitionCollection ;
1015use PhpSpec \ObjectBehavior ;
1116use Prophecy \Argument ;
1217use EzSystems \EzPlatformGraphQL \Schema \Domain ;
1318use EzSystems \EzPlatformGraphQL \Schema \Builder ;
19+ use Ibexa \GraphQL \Schema \Domain \NameValidator ;
1420
1521class ContentDomainIteratorSpec extends ObjectBehavior
1622{
17- public function let (ContentTypeService $ contentTypeService )
18- {
19- $ this ->beConstructedWith ($ contentTypeService );
23+ public function let (
24+ ContentTypeService $ contentTypeService ,
25+ NameValidator $ nameValidator
26+ ) {
27+ $ this ->beConstructedWith ($ contentTypeService , $ nameValidator );
2028 }
2129
22- function it_is_initializable ()
30+ public function it_is_initializable ()
2331 {
2432 $ this ->shouldHaveType (Domain \Iterator::class);
2533 }
2634
27- function it_initializes_the_schema_with_the_Platform_root_type (Builder $ schema )
35+ public function it_initializes_the_schema_with_the_Platform_root_type (Builder $ schema )
2836 {
2937 $ this ->init ($ schema );
3038
@@ -36,7 +44,7 @@ function it_initializes_the_schema_with_the_Platform_root_type(Builder $schema)
3644 )->shouldHaveBeenCalled ();
3745 }
3846
39- function it_yields_content_type_groups (ContentTypeService $ contentTypeService )
47+ public function it_yields_content_type_groups (ContentTypeService $ contentTypeService )
4048 {
4149 $ contentTypeService ->loadContentTypeGroups ()->willReturn ([
4250 $ group1 = new ContentTypeGroup (['identifier ' => 'Group 1 ' ]),
@@ -54,9 +62,12 @@ function it_yields_content_type_groups(ContentTypeService $contentTypeService)
5462 );
5563 }
5664
57- function it_yields_content_types_with_their_group_from_a_content_type_group (
58- ContentTypeService $ contentTypeService
65+ public function it_yields_content_types_with_their_group_from_a_content_type_group (
66+ ContentTypeService $ contentTypeService ,
67+ NameValidator $ nameValidator
5968 ) {
69+ $ nameValidator ->isValidName (Argument::any ())->willReturn (true );
70+
6071 $ contentTypeService ->loadContentTypeGroups ()->willReturn ([
6172 $ group = new ContentTypeGroup (['identifier ' => 'Group ' ]),
6273 ]);
@@ -76,9 +87,12 @@ function it_yields_content_types_with_their_group_from_a_content_type_group(
7687 );
7788 }
7889
79- function it_yields_fields_definitions_with_their_content_types_and_group_from_a_content_type (
80- ContentTypeService $ contentTypeService
90+ public function it_yields_fields_definitions_with_their_content_types_and_group_from_a_content_type (
91+ ContentTypeService $ contentTypeService ,
92+ NameValidator $ nameValidator
8193 ) {
94+ $ nameValidator ->isValidName (Argument::any ())->willReturn (true );
95+
8296 $ contentTypeService ->loadContentTypeGroups ()->willReturn ([
8397 $ group = new ContentTypeGroup (['identifier ' => 'Group ' ]),
8498 ]);
@@ -89,7 +103,7 @@ function it_yields_fields_definitions_with_their_content_types_and_group_from_a_
89103 'field1 ' => $ field1 = new FieldDefinition (['identifier ' => 'foo ' ]),
90104 'field2 ' => $ field2 = new FieldDefinition (['identifier ' => 'bar ' ]),
91105 'field3 ' => $ field3 = new FieldDefinition (['identifier ' => 'faz ' ]),
92- ])
106+ ]),
93107 ]),
94108 ]);
95109
@@ -104,12 +118,15 @@ function it_yields_fields_definitions_with_their_content_types_and_group_from_a_
104118 );
105119 }
106120
107- function it_only_yields_fields_definitions_from_the_current_content_type (
108- ContentTypeService $ contentTypeService
121+ public function it_only_yields_fields_definitions_from_the_current_content_type (
122+ ContentTypeService $ contentTypeService ,
123+ NameValidator $ nameValidator
109124 ) {
125+ $ nameValidator ->isValidName (Argument::any ())->willReturn (true );
126+
110127 $ contentTypeService ->loadContentTypeGroups ()->willReturn ([
111128 $ group = new ContentTypeGroup ([
112- 'identifier ' => 'group '
129+ 'identifier ' => 'group ' ,
113130 ]),
114131 ]);
115132
@@ -118,13 +135,13 @@ function it_only_yields_fields_definitions_from_the_current_content_type(
118135 'identifier ' => 'type1 ' ,
119136 'fieldDefinitions ' => new FieldDefinitionCollection ([
120137 'type1_field1 ' => ($ type1field1 = new FieldDefinition (['identifier ' => 'foo ' ])),
121- ])
138+ ]),
122139 ]),
123140 $ type2 = new ContentType ([
124141 'identifier ' => 'type2 ' ,
125142 'fieldDefinitions ' => new FieldDefinitionCollection ([
126143 'type2_field1 ' => ($ type2field1 = new FieldDefinition (['identifier ' => 'bar ' ])),
127- ])
144+ ]),
128145 ]),
129146 ]);
130147
0 commit comments