Passed
Branch master (461ffe)
by João Felipe Magro
05:37 queued 02:32
created

CartTest::testGetCartProductsIfItNotSetted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Tests\Classes;
4
5
use Ipag\Classes\Cart;
6
use Ipag\Classes\Product;
7
use PHPUnit\Framework\TestCase;
8
9
class CartTest extends TestCase
10
{
11
    private $product;
12
13
    public function setUp()
14
    {
15
        parent::setUp();
16
17
        $this->product = new Product();
18
        $this->product->setName('Produto de Testes')
19
            ->setQuantity(10)
20
            ->setUnitPrice(1.99)
21
            ->setSku('ABCD123');
22
    }
23
24
    public function testCreateAndAddAProductToCart()
25
    {
26
        $cart = new Cart();
27
28
        $cart->addProduct($this->product);
29
30
        $this->assertEquals(count($cart->getProducts()), 1);
31
    }
32
33
    public function testCreateAndAddManyProductsToCart()
34
    {
35
        $cart = new Cart();
36
37
        $products = [
38
            $this->product,
39
            $this->product,
40
            $this->product,
41
        ];
42
43
        $cart->addProducts($products);
44
45
        $this->assertEquals(count($cart->getProducts()), 3);
46
    }
47
48
    public function testGetCartProductsIfItNotSetted()
49
    {
50
        $cart = new Cart();
51
52
        $this->assertEquals([], $cart->getProducts());
53
    }
54
}
55