Skip to content

Commit 1ebef03

Browse files
committed
Added test to check if valid JSON is returned, when a document object is casted to a string
1 parent fe66bc2 commit 1ebef03

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/DocumentBasicTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,23 @@ public function testCreateAndDeleteDocumentUsingDefinedKeyWithArrayAndSaveOnly()
467467
$documentHandler->removeById($collection->getName(), $documentId);
468468
}
469469

470+
/**
471+
* Try to create a document and get valid JSON when casted to string.
472+
*/
473+
public function testCreateAndVerifyValidJsonIsReturnedWhenCastedToString()
474+
{
475+
$document = Document::createFromArray(
476+
['someAttribute' => 'someValue', 'someOtherAttribute' => 'someOtherValue']
477+
);
478+
479+
$stringDocument = (string) $document;
480+
481+
static::assertSame(
482+
$stringDocument, '{"someAttribute":"someValue","someOtherAttribute":"someOtherValue"}', 'Resulting Attribute should be {"someAttribute":"someValue","someOtherAttribute":"someOtherValue"}. It\'s :' . $stringDocument
483+
);
484+
485+
}
486+
470487

471488
public function testHasDocumentReturnsFalseIfDocumentDoesNotExist()
472489
{

0 commit comments

Comments
 (0)