From a0cdac4457dc569d6db6aca197ae3c7391893440 Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 14:17:19 +0700 Subject: [PATCH 01/14] Update index.blade.php --- resources/views/products/index.blade.php | 29 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/resources/views/products/index.blade.php b/resources/views/products/index.blade.php index 1150158..06918bd 100644 --- a/resources/views/products/index.blade.php +++ b/resources/views/products/index.blade.php @@ -35,7 +35,7 @@ {{ $product->quantity }} {{ $product->price }} -
+ @csrf @method('DELETE') @@ -43,7 +43,7 @@ Edit - +
@@ -63,5 +63,26 @@ - -@endsection + +@forelse ($products as $product) + +@empty +@endforelse + +@endsection \ No newline at end of file From c61a989e209eb16048065485a53ff7651a6a4872 Mon Sep 17 00:00:00 2001 From: Rihanrh <91171771+Rihanrh@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:26:31 +0700 Subject: [PATCH 02/14] Create laravel.yml --- .github/workflows/laravel.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/laravel.yml diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml new file mode 100644 index 0000000..c690791 --- /dev/null +++ b/.github/workflows/laravel.yml @@ -0,0 +1,35 @@ +name: Laravel + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + laravel-tests: + + runs-on: ubuntu-latest + + steps: + - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e + with: + php-version: '8.0' + - uses: actions/checkout@v4 + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.example', '.env');" + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Generate key + run: php artisan key:generate + - name: Directory Permissions + run: chmod -R 777 storage bootstrap/cache + - name: Create Database + run: | + mkdir -p database + touch database/database.sqlite + - name: Execute tests (Unit and Feature tests) via PHPUnit/Pest + env: + DB_CONNECTION: sqlite + DB_DATABASE: database/database.sqlite + run: php artisan test From e218acd80677b3359e54d5aacceabafa7c94b57d Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 14:28:52 +0700 Subject: [PATCH 03/14] Update laravel.yml --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index c690791..4535182 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -19,7 +19,7 @@ jobs: - name: Copy .env run: php -r "file_exists('.env') || copy('.env.example', '.env');" - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + run: composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: Generate key run: php artisan key:generate - name: Directory Permissions From fede92ee41f33347b6b138d33002df7b20973538 Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 14:29:54 +0700 Subject: [PATCH 04/14] Delete laravel.yml --- .github/workflows/laravel.yml | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 .github/workflows/laravel.yml diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml deleted file mode 100644 index 4535182..0000000 --- a/.github/workflows/laravel.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Laravel - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - laravel-tests: - - runs-on: ubuntu-latest - - steps: - - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e - with: - php-version: '8.0' - - uses: actions/checkout@v4 - - name: Copy .env - run: php -r "file_exists('.env') || copy('.env.example', '.env');" - - name: Install Dependencies - run: composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Generate key - run: php artisan key:generate - - name: Directory Permissions - run: chmod -R 777 storage bootstrap/cache - - name: Create Database - run: | - mkdir -p database - touch database/database.sqlite - - name: Execute tests (Unit and Feature tests) via PHPUnit/Pest - env: - DB_CONNECTION: sqlite - DB_DATABASE: database/database.sqlite - run: php artisan test From 1588d2257b6068f3b9dd78bcec5b77e8dc794cd8 Mon Sep 17 00:00:00 2001 From: Rihanrh <91171771+Rihanrh@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:30:36 +0700 Subject: [PATCH 05/14] Create laravel.yml --- .github/workflows/laravel.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/laravel.yml diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml new file mode 100644 index 0000000..4535182 --- /dev/null +++ b/.github/workflows/laravel.yml @@ -0,0 +1,35 @@ +name: Laravel + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + laravel-tests: + + runs-on: ubuntu-latest + + steps: + - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e + with: + php-version: '8.0' + - uses: actions/checkout@v4 + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.example', '.env');" + - name: Install Dependencies + run: composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Generate key + run: php artisan key:generate + - name: Directory Permissions + run: chmod -R 777 storage bootstrap/cache + - name: Create Database + run: | + mkdir -p database + touch database/database.sqlite + - name: Execute tests (Unit and Feature tests) via PHPUnit/Pest + env: + DB_CONNECTION: sqlite + DB_DATABASE: database/database.sqlite + run: php artisan test From 1157fb8c366c89cac4391a62a5e01d6fa519b374 Mon Sep 17 00:00:00 2001 From: Rihanrh <91171771+Rihanrh@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:33:43 +0700 Subject: [PATCH 06/14] Delete .github/workflows directory --- .github/workflows/laravel.yml | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 .github/workflows/laravel.yml diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml deleted file mode 100644 index 4535182..0000000 --- a/.github/workflows/laravel.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Laravel - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - laravel-tests: - - runs-on: ubuntu-latest - - steps: - - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e - with: - php-version: '8.0' - - uses: actions/checkout@v4 - - name: Copy .env - run: php -r "file_exists('.env') || copy('.env.example', '.env');" - - name: Install Dependencies - run: composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Generate key - run: php artisan key:generate - - name: Directory Permissions - run: chmod -R 777 storage bootstrap/cache - - name: Create Database - run: | - mkdir -p database - touch database/database.sqlite - - name: Execute tests (Unit and Feature tests) via PHPUnit/Pest - env: - DB_CONNECTION: sqlite - DB_DATABASE: database/database.sqlite - run: php artisan test From c814666fa8f5563f568423bcbca7a8399ce39f14 Mon Sep 17 00:00:00 2001 From: Rihanrh <91171771+Rihanrh@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:34:05 +0700 Subject: [PATCH 07/14] Create laravel.yml --- .github/workflows/laravel.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/laravel.yml diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml new file mode 100644 index 0000000..a704ebc --- /dev/null +++ b/.github/workflows/laravel.yml @@ -0,0 +1,35 @@ +name: Laravel + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + laravel-tests: + + runs-on: ubuntu-latest + + steps: + - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e + with: + php-version: '8.1' # Updated PHP version to 8.1 + - uses: actions/checkout@v4 + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.example', '.env');" + - name: Install Dependencies + run: composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Generate key + run: php artisan key:generate + - name: Directory Permissions + run: chmod -R 777 storage bootstrap/cache + - name: Create Database + run: | + mkdir -p database + touch database/database.sqlite + - name: Execute tests (Unit and Feature tests) via PHPUnit/Pest + env: + DB_CONNECTION: sqlite + DB_DATABASE: database/database.sqlite + run: php artisan test From 914994ab0d1f3b03b19fae80d3f98c69ff90d658 Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 14:46:35 +0700 Subject: [PATCH 08/14] Update composer.lock --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 183f533..e9f5081 100644 --- a/composer.lock +++ b/composer.lock @@ -8057,5 +8057,5 @@ "php": "^8.1" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From 60b91ea3b024a99b3a9275581c91f0ce69d5f2a3 Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 14:47:47 +0700 Subject: [PATCH 09/14] Update laravel.yml --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index a704ebc..f7387ed 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -19,7 +19,7 @@ jobs: - name: Copy .env run: php -r "file_exists('.env') || copy('.env.example', '.env');" - name: Install Dependencies - run: composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: Generate key run: php artisan key:generate - name: Directory Permissions From 574cfb09263ee88e561a64150acb0669559bf59f Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 14:49:35 +0700 Subject: [PATCH 10/14] Update laravel.yml --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index f7387ed..c690791 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e with: - php-version: '8.1' # Updated PHP version to 8.1 + php-version: '8.0' - uses: actions/checkout@v4 - name: Copy .env run: php -r "file_exists('.env') || copy('.env.example', '.env');" From 89a4e83c36273182125aa2055dc401bdf1489e8f Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 14:50:16 +0700 Subject: [PATCH 11/14] Update laravel.yml --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index c690791..c812e64 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e with: - php-version: '8.0' + php-version: '8.1' - uses: actions/checkout@v4 - name: Copy .env run: php -r "file_exists('.env') || copy('.env.example', '.env');" From e0943cb4eec8ce7c78aec4db1a17f90458af9733 Mon Sep 17 00:00:00 2001 From: Rihanrh Date: Wed, 5 Jun 2024 15:01:42 +0700 Subject: [PATCH 12/14] Added Tests --- tests/Feature/funcCreateTest.php | 26 +++++++++++++++++ tests/Feature/funcDeleteTest.php | 38 +++++++++++++++++++++++++ tests/Feature/funcUpdateTest.php | 48 ++++++++++++++++++++++++++++++++ tests/Feature/funcViewTest.php | 33 ++++++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 tests/Feature/funcCreateTest.php create mode 100644 tests/Feature/funcDeleteTest.php create mode 100644 tests/Feature/funcUpdateTest.php create mode 100644 tests/Feature/funcViewTest.php diff --git a/tests/Feature/funcCreateTest.php b/tests/Feature/funcCreateTest.php new file mode 100644 index 0000000..830b42a --- /dev/null +++ b/tests/Feature/funcCreateTest.php @@ -0,0 +1,26 @@ +get(route('products.create')); + + $response->assertStatus(200); + + $response->assertViewIs('products.create'); + } +} diff --git a/tests/Feature/funcDeleteTest.php b/tests/Feature/funcDeleteTest.php new file mode 100644 index 0000000..4b475f0 --- /dev/null +++ b/tests/Feature/funcDeleteTest.php @@ -0,0 +1,38 @@ + 'P12345', + 'name' => 'Product to be deleted', + 'quantity' => 10, + 'price' => 99.99, + 'description' => 'Product description', + ]); + + // Send the delete request + $response = $this->delete(route('products.destroy', $product->id)); + + // Assert the response status + $response->assertRedirect(route('products.index')); + $response->assertSessionHas('success', 'Product is deleted successfully.'); + + // Assert the product was deleted + $this->assertDatabaseMissing('products', ['id' => $product->id]); + } +} diff --git a/tests/Feature/funcUpdateTest.php b/tests/Feature/funcUpdateTest.php new file mode 100644 index 0000000..390f090 --- /dev/null +++ b/tests/Feature/funcUpdateTest.php @@ -0,0 +1,48 @@ + 'H001', + 'name' => 'Kaveh', + 'quantity' => 1, + 'price' => 99.99, + 'description' => 'Husbunya Ren', + ]); + + $updateData = [ + 'code' => 'H001', + 'name' => 'Kaveh', + 'quantity' => 1, + 'price' => 199.99, + 'description' => 'Malewife keduanya Ren', + ]; + + $response = $this->put(route('products.update', $product->id), $updateData); + + $response->assertRedirect(); + $response->assertSessionHas('success', 'Product is updated successfully.'); + + $updatedProduct = Product::find($product->id); + + $this->assertEquals($updateData['code'], $updatedProduct->code); + $this->assertEquals($updateData['name'], $updatedProduct->name); + $this->assertEquals($updateData['quantity'], $updatedProduct->quantity); + $this->assertEquals($updateData['price'], $updatedProduct->price); + $this->assertEquals($updateData['description'], $updatedProduct->description); + } +} diff --git a/tests/Feature/funcViewTest.php b/tests/Feature/funcViewTest.php new file mode 100644 index 0000000..e54c1d5 --- /dev/null +++ b/tests/Feature/funcViewTest.php @@ -0,0 +1,33 @@ + 'H001', + 'name' => 'Kaveh', + 'quantity' => 1, + 'price' => 99.99, + 'description' => 'Husbunya Ren', + ]); + + $response = $this->get(route('products.show', $product->id)); + + $response->assertStatus(200); + $response->assertViewIs('products.show'); + $response->assertViewHas('product', $product); + } +} From 980441eec50db5f63fbf5c1c7538b50a32bf2fd7 Mon Sep 17 00:00:00 2001 From: jaatsiyah Date: Wed, 5 Jun 2024 21:08:14 +0700 Subject: [PATCH 13/14] update funcViewTest --- tests/Feature/funcViewTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/funcViewTest.php b/tests/Feature/funcViewTest.php index e54c1d5..de7d833 100644 --- a/tests/Feature/funcViewTest.php +++ b/tests/Feature/funcViewTest.php @@ -17,7 +17,7 @@ class funcViewTest extends TestCase public function test_show_product(): void { $product = Product::create([ - 'code' => 'H001', + 'code' => 'H0012', 'name' => 'Kaveh', 'quantity' => 1, 'price' => 99.99, From 90b74210fb9560c1e81c28597e0584ddc72ef315 Mon Sep 17 00:00:00 2001 From: jaatsiyah Date: Thu, 13 Jun 2024 19:15:59 +0700 Subject: [PATCH 14/14] Update viewTest --- tests/Feature/funcViewTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/funcViewTest.php b/tests/Feature/funcViewTest.php index de7d833..093e4f2 100644 --- a/tests/Feature/funcViewTest.php +++ b/tests/Feature/funcViewTest.php @@ -18,7 +18,7 @@ public function test_show_product(): void { $product = Product::create([ 'code' => 'H0012', - 'name' => 'Kaveh', + 'name' => 'Kaaveh', 'quantity' => 1, 'price' => 99.99, 'description' => 'Husbunya Ren',