From 002e372b58484e9dd9f8d995fe60a11ba54e38fb Mon Sep 17 00:00:00 2001 From: Mohammad Mortazavi Date: Mon, 28 Aug 2023 15:12:19 +0330 Subject: [PATCH] two test model created; --- tests/Core/Models/Post.php | 19 +++++++++++ tests/Core/Models/Product.php | 20 ++++++++++++ .../2023_08_25_100000_create_posts_table.php | 31 ++++++++++++++++++ ...023_08_25_100001_create_products_table.php | 32 +++++++++++++++++++ tests/TestCase.php | 1 + 5 files changed, 103 insertions(+) create mode 100644 tests/Core/Models/Post.php create mode 100644 tests/Core/Models/Product.php create mode 100644 tests/Core/migrations/2023_08_25_100000_create_posts_table.php create mode 100644 tests/Core/migrations/2023_08_25_100001_create_products_table.php diff --git a/tests/Core/Models/Post.php b/tests/Core/Models/Post.php new file mode 100644 index 0000000..1418d50 --- /dev/null +++ b/tests/Core/Models/Post.php @@ -0,0 +1,19 @@ +morphToMany( Invoice::class, 'invoicable' ); + } + } \ No newline at end of file diff --git a/tests/Core/Models/Product.php b/tests/Core/Models/Product.php new file mode 100644 index 0000000..08a9b5d --- /dev/null +++ b/tests/Core/Models/Product.php @@ -0,0 +1,20 @@ +morphToMany( Invoice::class, 'invoicable' ); + } + + } \ No newline at end of file diff --git a/tests/Core/migrations/2023_08_25_100000_create_posts_table.php b/tests/Core/migrations/2023_08_25_100000_create_posts_table.php new file mode 100644 index 0000000..f2e8ad9 --- /dev/null +++ b/tests/Core/migrations/2023_08_25_100000_create_posts_table.php @@ -0,0 +1,31 @@ +getTable(), function( Blueprint $table ) { + $table->id(); + $table->string( 'title' ); + $table->text( 'description' ); + $table->timestamps(); + } ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void { + Schema::dropIfExists( ( new Post )->getTable() ); + } + }; diff --git a/tests/Core/migrations/2023_08_25_100001_create_products_table.php b/tests/Core/migrations/2023_08_25_100001_create_products_table.php new file mode 100644 index 0000000..09afe22 --- /dev/null +++ b/tests/Core/migrations/2023_08_25_100001_create_products_table.php @@ -0,0 +1,32 @@ +getTable(), function( Blueprint $table ) { + $table->id(); + $table->string( 'name' ); + $table->string( 'brand' ); + $table->timestamps(); + } ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void { + Schema::dropIfExists( ( new Product )->getTable() ); + } + }; diff --git a/tests/TestCase.php b/tests/TestCase.php index 416c3c3..b024e1f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -21,6 +21,7 @@ class TestCase extends BaseTestCase protected function setUp(): void { parent::setUp(); + $this->loadMigrationsFrom(__DIR__.'/Core/migrations'); $this->client = new Client; }