File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
docs/includes/eloquent-models Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace App \Tests ;
6
+
7
+ use App \Models \Planet ;
8
+ use MongoDB \Laravel \Tests \TestCase ;
9
+
10
+ class SchemaVersionTest extends TestCase
11
+ {
12
+ /**
13
+ * @runInSeparateProcess
14
+ * @preserveGlobalState disabled
15
+ */
16
+ public function testSchemaVersion (): void
17
+ {
18
+ require_once __DIR__ . '/PlanetSchemaVersion.php ' ;
19
+
20
+ Planet::truncate ();
21
+
22
+ $ saturn = Planet::create ([
23
+ 'name ' => 'Saturn ' ,
24
+ 'type ' => 'gas ' ,
25
+ ]);
26
+
27
+ $ wasp = Planet::create ([
28
+ 'name ' => 'WASP-39 b ' ,
29
+ 'type ' => 'gas ' ,
30
+ 'schema_version ' => 1 ,
31
+ ]);
32
+
33
+ $ planets = Planet::where ('type ' , 'gas ' )
34
+ ->get ();
35
+ echo 'After migration:\n ' . $ planets [0 ];
36
+
37
+ $ this ->assertCount (2 , $ planets );
38
+ $ this ->assertEquals (2 , $ planets [0 ]->schema_version );
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments