-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDateTimeFormatNeo4jTest.php
More file actions
59 lines (49 loc) · 1.54 KB
/
DateTimeFormatNeo4jTest.php
File metadata and controls
59 lines (49 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare( strict_types = 1 );
namespace phpunit\Persistence\Neo4j\Formats;
use ProfessionalWiki\NeoWiki\Domain\Schema\PropertyName;
use ProfessionalWiki\NeoWiki\Domain\Statement;
use ProfessionalWiki\NeoWiki\Domain\Subject\StatementList;
use ProfessionalWiki\NeoWiki\Domain\Value\StringValue;
use ProfessionalWiki\NeoWiki\Domain\PropertyType\Types\DateTimeType;
use ProfessionalWiki\NeoWiki\Tests\Data\TestPage;
use ProfessionalWiki\NeoWiki\Tests\Data\TestSubject;
use ProfessionalWiki\NeoWiki\Tests\NeoWikiIntegrationTestCase;
/**
* @group Database
*/
class DateTimeFormatNeo4jTest extends NeoWikiIntegrationTestCase {
public function setUp(): void {
$this->setUpNeo4j();
}
public function testStoresAsDateTimes(): void {
$store = $this->newNeo4jQueryStore();
$subjectId = TestSubject::uniqueId();
$store->savePage( TestPage::build(
mainSubject: TestSubject::build(
id: $subjectId,
statements: new StatementList( [
new Statement(
property: new PropertyName( 'MyProperty' ),
propertyType: DateTimeType::NAME,
value: new StringValue(
'2023-09-13T14:22:23Z',
'2150-12-07T13:37:42+02:00',
)
),
] )
),
) );
$result = $store->runReadQuery(
"MATCH (n {id: '$subjectId'})
RETURN n.MyProperty = [
datetime('2023-09-13T14:22:23Z'),
datetime('2150-12-07T13:37:42+02:00')
] AS isDatetimeList"
);
$this->assertTrue(
$result->first()->toRecursiveArray()['isDatetimeList'],
'dateTime statement values should be stored as a list of Neo4j datetimes'
);
}
}