![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mcoil.corals.io/tests/Unit/CustomerTypes/ |
<?php namespace Tests\Unit\CustomerTypes; use App\Shop\CustomerTypes\CustomerType; use App\Shop\CustomerTypes\Repositories\CustomerTypeRepository; use Illuminate\Support\Collection; use Tests\TestCase; class CustomerTypeUnitTest extends TestCase { /** @test */ public function it_can_show_all_the_customer_types() { factory(CustomerType::class, 3)->create(); $customerTypeRepo = new CustomerTypeRepository(new CustomerType); $list = $customerTypeRepo->listCustomerTypes(); $this->assertInstanceOf(Collection::class, $list); $this->assertCount(3, $list->all()); } /** @test */ public function it_can_delete_the_customer_type() { $customerType = factory(CustomerType::class)->create(); $customerTypeRepo = new CustomerTypeRepository($customerType); $deleted = $customerTypeRepo->deleteCustomerType($customerType->id); $this->assertTrue($deleted); } /** @test */ public function it_can_update_the_customer_type() { $customerType = factory(CustomerType::class)->create(); $data = ['name' => 'Business']; $customerTypeRepo = new CustomerTypeRepository($customerType); $updated = $customerTypeRepo->updateCustomerType($data); $found = $customerTypeRepo->findCustomerTypeById($customerType->id); $this->assertTrue($updated); $this->assertEquals($data['name'], $found->name); } /** @test */ public function it_can_show_the_customer_type() { $customerType = factory(CustomerType::class)->create(); $customerTypeRepo = new CustomerTypeRepository(new CustomerType); $found = $customerTypeRepo->findCustomerTypeById($customerType->id); $this->assertInstanceOf(CustomerType::class, $found); $this->assertEquals($customerType->name, $found->name); } /** @test */ public function it_can_create_a_customer_type() { $data = ['name' => $this->faker->word,'description' => $this->faker->paragraph]; $customerTypeRepo = new CustomerTypeRepository(new CustomerType); $customerType = $customerTypeRepo->createCustomerType($data); $this->assertInstanceOf(CustomerType::class, $customerType); $this->assertEquals($data['name'], $customerType->name); $this->assertEquals($data['description'], $customerType->description); } }