File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
fixtures/MigrationGeneratorTest Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 33namespace RonasIT \Support \Tests ;
44
55use Illuminate \Support \Carbon ;
6+ use Illuminate \Support \Facades \Config ;
67use RonasIT \Support \Exceptions \UnknownFieldTypeException ;
78use RonasIT \Support \Generators \MigrationGenerator ;
89
@@ -72,9 +73,35 @@ public function testCreateMigrationMYSQL()
7273 'string ' => ['title ' , 'body ' ],
7374 'json ' => ['meta ' ],
7475 'timestamp ' => ['created_at ' ],
76+ 'timestamp-required ' => ['published_at ' ],
7577 ])
7678 ->generate ();
7779
7880 $ this ->assertGeneratedFileEquals ('migrations_mysql.php ' , 'database/migrations/2022_02_02_000000_posts_create_table.php ' );
7981 }
82+
83+ public function testCreateMigrationWithoutMigrationStub (): void
84+ {
85+ Carbon::setTestNow ('2022-02-02 ' );
86+
87+ Config::set ('entity-generator.stubs.migration ' );
88+
89+ $ result = app (MigrationGenerator::class)
90+ ->setModel ('Post ' )
91+ ->setRelations ([
92+ 'belongsTo ' => [],
93+ 'belongsToMany ' => [],
94+ 'hasOne ' => [],
95+ 'hasMany ' => [],
96+ ])
97+ ->setFields ([
98+ 'integer-required ' => ['media_id ' , 'user_id ' ],
99+ 'string ' => ['title ' , 'body ' ],
100+ 'json ' => ['meta ' ],
101+ 'timestamp ' => ['created_at ' ],
102+ ])
103+ ->generate ();
104+
105+ $ this ->assertNull ($ result );
106+ }
80107}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public function up(): void
1919 $ table ->string ('body ' )->nullable ();
2020 $ table ->json ('meta ' )->nullable ();
2121 $ table ->timestamp ('created_at ' )->nullable ();
22+ $ table ->timestamp ('published_at ' )->nullable ();
2223 $ table ->timestamps ();
2324 });
2425 }
You can’t perform that action at this time.
0 commit comments