Skip to content

Commit 0902764

Browse files
committed
Add attribute with schema
1 parent a78d777 commit 0902764

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/e2e/Adapter/Scopes/CollectionTests.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ public function testCreateCollectionWithSchema(): void
107107
'array' => false,
108108
'filters' => [],
109109
]),
110+
new Document([
111+
'$id' => ID::custom('attribute4'),
112+
'type' => Database::VAR_ID,
113+
'size' => 0,
114+
'required' => false,
115+
'signed' => false,
116+
'array' => false,
117+
'filters' => [],
118+
]),
110119
];
111120

112121
$indexes = [
@@ -131,6 +140,13 @@ public function testCreateCollectionWithSchema(): void
131140
'lengths' => [],
132141
'orders' => ['DESC', 'ASC'],
133142
]),
143+
new Document([
144+
'$id' => ID::custom('index4'),
145+
'type' => Database::INDEX_KEY,
146+
'attributes' => ['attribute4'],
147+
'lengths' => [],
148+
'orders' => ['DESC', 'ASC'],
149+
]),
134150
];
135151

136152
$collection = $database->createCollection('withSchema', $attributes, $indexes);
@@ -139,22 +155,27 @@ public function testCreateCollectionWithSchema(): void
139155
$this->assertEquals('withSchema', $collection->getId());
140156

141157
$this->assertIsArray($collection->getAttribute('attributes'));
142-
$this->assertCount(3, $collection->getAttribute('attributes'));
158+
$this->assertCount(4, $collection->getAttribute('attributes'));
143159
$this->assertEquals('attribute1', $collection->getAttribute('attributes')[0]['$id']);
144160
$this->assertEquals(Database::VAR_STRING, $collection->getAttribute('attributes')[0]['type']);
145161
$this->assertEquals('attribute2', $collection->getAttribute('attributes')[1]['$id']);
146162
$this->assertEquals(Database::VAR_INTEGER, $collection->getAttribute('attributes')[1]['type']);
147163
$this->assertEquals('attribute3', $collection->getAttribute('attributes')[2]['$id']);
148164
$this->assertEquals(Database::VAR_BOOLEAN, $collection->getAttribute('attributes')[2]['type']);
165+
$this->assertEquals('attribute4', $collection->getAttribute('attributes')[3]['$id']);
166+
$this->assertEquals(Database::VAR_ID, $collection->getAttribute('attributes')[3]['type']);
149167

150168
$this->assertIsArray($collection->getAttribute('indexes'));
151-
$this->assertCount(3, $collection->getAttribute('indexes'));
169+
$this->assertCount(4, $collection->getAttribute('indexes'));
152170
$this->assertEquals('index1', $collection->getAttribute('indexes')[0]['$id']);
153171
$this->assertEquals(Database::INDEX_KEY, $collection->getAttribute('indexes')[0]['type']);
154172
$this->assertEquals('index2', $collection->getAttribute('indexes')[1]['$id']);
155173
$this->assertEquals(Database::INDEX_KEY, $collection->getAttribute('indexes')[1]['type']);
156174
$this->assertEquals('index3', $collection->getAttribute('indexes')[2]['$id']);
157175
$this->assertEquals(Database::INDEX_KEY, $collection->getAttribute('indexes')[2]['type']);
176+
$this->assertEquals('index4', $collection->getAttribute('indexes')[3]['$id']);
177+
$this->assertEquals(Database::INDEX_KEY, $collection->getAttribute('indexes')[3]['type']);
178+
158179

159180
$database->deleteCollection('withSchema');
160181

0 commit comments

Comments
 (0)