File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed
Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 66
77use DateTimeInterface ;
88use Psr \Http \Message \UploadedFileInterface ;
9+ use TheCodingMachine \GraphQLite \Annotations \Field ;
910use TheCodingMachine \GraphQLite \Annotations \Type ;
1011
1112/**
@@ -33,6 +34,10 @@ class Contact
3334 * @var DateTimeInterface
3435 */
3536 private $ birthDate ;
37+ /**
38+ * @var string
39+ */
40+ private $ company ;
3641
3742 public function __construct (string $ name )
3843 {
@@ -107,4 +112,23 @@ public function setBirthDate(DateTimeInterface $birthDate): void
107112 {
108113 $ this ->birthDate = $ birthDate ;
109114 }
115+
116+ /**
117+ * Here, we are testing overriding the field in the extend class.
118+ *
119+ * @Field()
120+ * @return string
121+ */
122+ public function getCompany (): string
123+ {
124+ return $ this ->company ;
125+ }
126+
127+ /**
128+ * @param string $company
129+ */
130+ public function setCompany (string $ company ): void
131+ {
132+ $ this ->company = $ company ;
133+ }
110134}
Original file line number Diff line number Diff line change @@ -22,4 +22,15 @@ public function uppercaseName(Contact $contact): string
2222 {
2323 return strtoupper ($ contact ->getName ());
2424 }
25- }
25+
26+ /**
27+ * Here, we are testing overriding the field in the extend class.
28+ *
29+ * @Field()
30+ * @return string
31+ */
32+ public function company (Contact $ contact ): string
33+ {
34+ return $ contact ->getName ().' Ltd ' ;
35+ }
36+ }
Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ public function testEndToEnd()
195195 query {
196196 contacts {
197197 name
198+ company
198199 uppercaseName
199200 ... on User {
200201 email
@@ -212,10 +213,12 @@ public function testEndToEnd()
212213 'contacts ' => [
213214 [
214215 'name ' => 'Joe ' ,
216+ 'company ' => 'Joe Ltd ' ,
215217 'uppercaseName ' => 'JOE '
216218 ],
217219 [
218220 'name ' => 'Bill ' ,
221+ 'company ' => 'Bill Ltd ' ,
219222 'uppercaseName ' => 'BILL ' ,
220223 'email ' => 'bill@example.com '
221224 ]
@@ -233,10 +236,12 @@ public function testEndToEnd()
233236 'contacts ' => [
234237 [
235238 'name ' => 'Joe ' ,
239+ 'company ' => 'Joe Ltd ' ,
236240 'uppercaseName ' => 'JOE '
237241 ],
238242 [
239243 'name ' => 'Bill ' ,
244+ 'company ' => 'Bill Ltd ' ,
240245 'uppercaseName ' => 'BILL ' ,
241246 'email ' => 'bill@example.com '
242247 ]
You can’t perform that action at this time.
0 commit comments