File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,10 +97,10 @@ public function toArray(): array
9797 return [
9898 'category ' => 'doc ' ,
9999 'attributes ' => null ,
100- 'content ' => $ this ->content
100+ 'content ' => $ this ->content ,
101101 ];
102102 }
103-
103+
104104 /**
105105 * Return a JSON serialization of the document node
106106 */
@@ -115,7 +115,6 @@ public function jsonSerialize(): mixed
115115 return $ this ->toArray ();
116116 }
117117
118-
119118 /**
120119 * Create a document node from associative array
121120 */
@@ -154,10 +153,10 @@ public static function fromString(string $data): DocumentNode
154153 'content ' => $ data ,
155154 'marks ' => [],
156155 'attributes ' => [],
157- ]
158- ]
159- ]
160- ]
156+ ],
157+ ],
158+ ],
159+ ],
161160 ]);
162161 }
163162}
Original file line number Diff line number Diff line change 55use OneOffTech \Parse \Client \Exceptions \InvalidDocumentFormatException ;
66
77test ('node created from string ' , function () {
8-
8+
99 $ document = DocumentNode::fromString ('test content ' );
1010
1111 expect ($ document )
4545 'content ' => 'This is the page one text ' ,
4646 'marks ' => [],
4747 'attributes ' => [],
48- ]
49- ]
50- ]
51- ]
48+ ],
49+ ],
50+ ],
51+ ],
5252 ]);
5353
5454 expect ($ document )
9191 'content ' => 'This is the page one text ' ,
9292 'marks ' => [],
9393 'attributes ' => [],
94- ]
95- ]
96- ]
97- ]
94+ ],
95+ ],
96+ ],
97+ ],
9898 ]);
9999
100100})->throws (InvalidDocumentFormatException::class, 'Unexpected document structure. Missing category or content. ' );
124124 'content ' => 'This is the page one text ' ,
125125 'marks ' => [],
126126 'attributes ' => [],
127- ]
128- ]
129- ]
130- ]
127+ ],
128+ ],
129+ ],
130+ ],
131131 ]);
132132
133133})->throws (InvalidDocumentFormatException::class, 'Unexpected node category. Expecting [doc] found [something]. ' );
136136 DocumentNode::fromArray ([
137137 'category ' => 'doc ' ,
138138 'attributes ' => null ,
139- 'content ' => 'a string '
139+ 'content ' => 'a string ' ,
140140 ]);
141141
142142})->throws (InvalidDocumentFormatException::class, 'Unexpected content format. Expecting [array]. ' );
143143
144-
145144test ('can be serialized in json ' , function () {
146145
147146 $ expectedContent = [
160159 'content ' => 'This is the page one text ' ,
161160 'marks ' => [],
162161 'attributes ' => [],
163- ]
164- ]
165- ]
166- ]
162+ ],
163+ ],
164+ ],
165+ ],
167166 ];
168167
169168 $ document = DocumentNode::fromArray ($ expectedContent );
You can’t perform that action at this time.
0 commit comments