Server IP : 103.11.96.170 / Your IP : 3.144.28.166 Web Server : Microsoft-IIS/10.0 System : Windows NT WIN-F6SLGVICLOP 10.0 build 17763 (Windows Server 2016) AMD64 User : elibrary.unsap.ac.id ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF Directory (0777) : D:/localhost/grosir/tests/Feature/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php namespace Tests\Feature; use App\Product; use App\Unit; use Illuminate\Foundation\Testing\DatabaseMigrations; use Tests\BrowserKitTestCase; class ManageProductsTest extends BrowserKitTestCase { use DatabaseMigrations; /** @test */ public function user_can_see_paginated_product_list_in_product_index_page() { $product1 = factory(Product::class)->create(['name' => 'Testing 123']); $product2 = factory(Product::class)->create(['name' => 'Testing 456']); $this->loginAsUser(); $this->visit(route('products.index')); $this->see($product1->name); $this->see($product2->name); } /** @test */ public function user_can_search_product_by_keyword() { $this->loginAsUser(); $product1 = factory(Product::class)->create(['name' => 'Testing 123']); $product2 = factory(Product::class)->create(['name' => 'Testing 456']); $this->visit(route('products.index')); $this->submitForm(trans('product.search'), ['q' => '123']); $this->seePageIs(route('products.index', ['q' => 123])); $this->see($product1->name); $this->dontSee($product2->name); } /** @test */ public function user_can_create_a_product() { $unit = factory(Unit::class)->create(['name' => 'Testing 123']); $this->loginAsUser(); $this->visit(route('products.index')); $this->click(trans('product.create')); $this->seePageIs(route('products.index', ['action' => 'create'])); $this->type('Product 1', 'name'); $this->type('1000', 'cash_price'); $this->type('1200', 'credit_price'); $this->type($unit->id, 'unit_id'); $this->press(trans('product.create')); $this->seePageIs(route('products.index')); // $this->see(trans('product.created')); $this->seeInDatabase('products', [ 'name' => 'Product 1', 'cash_price' => 1000, 'credit_price' => 1200, ]); } /** @test */ public function user_can_edit_a_product_within_search_query() { $unit = factory(Unit::class)->create(['name' => 'Testing 123']); $this->loginAsUser(); $product = factory(Product::class)->create(['name' => 'Testing 123']); $this->visit(route('products.index', ['q' => '123'])); $this->click('edit-product-'.$product->id); $this->seePageIs(route('products.index', ['action' => 'edit', 'id' => $product->id, 'q' => '123'])); $this->type('Product 1', 'name'); $this->type('1000', 'cash_price'); $this->type('1200', 'credit_price'); $this->type($unit->id, 'unit_id'); $this->press(trans('product.update')); $this->seePageIs(route('products.index', ['q' => '123'])); $this->seeInDatabase('products', [ 'name' => 'Product 1', 'cash_price' => 1000, 'credit_price' => 1200, ]); } /** @test */ public function user_can_create_a_product_with_only_cash_price() { $unit = factory(Unit::class)->create(['name' => 'Testing 123']); $this->loginAsUser(); $this->visit(route('products.index')); $this->click(trans('product.create')); $this->seePageIs(route('products.index', ['action' => 'create'])); $this->type('Product 1', 'name'); $this->type('1000', 'cash_price'); $this->type('', 'credit_price'); $this->type($unit->id, 'unit_id'); $this->press(trans('product.create')); $this->seePageIs(route('products.index')); // $this->see(trans('product.created')); $this->seeInDatabase('products', [ 'name' => 'Product 1', 'cash_price' => 1000, 'credit_price' => null, ]); } /** @test */ public function user_can_edit_a_product() { $unit = factory(Unit::class)->create(['name' => 'Testing 123']); $this->loginAsUser(); $product = factory(Product::class)->create(); $this->visit(route('products.index')); $this->click('edit-product-'.$product->id); $this->seePageIs(route('products.index', ['action' => 'edit', 'id' => $product->id])); $this->type('Product 1', 'name'); $this->type('1000', 'cash_price'); $this->type('1200', 'credit_price'); $this->type($unit->id, 'unit_id'); $this->press(trans('product.update')); $this->seeInDatabase('products', [ 'name' => 'Product 1', 'cash_price' => 1000, 'credit_price' => 1200, ]); } /** @test */ public function user_can_delete_a_product() { $this->loginAsUser(); $product = factory(Product::class)->create(); $this->visit(route('products.index')); $this->click('del-product-'.$product->id); $this->seePageIs(route('products.index', ['action' => 'delete', 'id' => $product->id])); $this->seeInDatabase('products', [ 'id' => $product->id, ]); $this->press(trans('app.delete_confirm_button')); $this->dontSeeInDatabase('products', [ 'id' => $product->id, ]); } /** @test */ public function user_can_delete_a_product_within_search_query() { $this->loginAsUser(); $product = factory(Product::class)->create(['name' => 'Product 123']); $this->visit(route('products.index', ['q' => '123'])); $this->click('del-product-'.$product->id); $this->seePageIs(route('products.index', ['action' => 'delete', 'id' => $product->id, 'q' => '123'])); $this->seeInDatabase('products', [ 'id' => $product->id, ]); $this->press(trans('app.delete_confirm_button')); $this->seePageIs(route('products.index', ['q' => '123'])); $this->dontSeeInDatabase('products', [ 'id' => $product->id, ]); } }