Passed
Push — master ( 8580f6...1081a5 )
by Laurent
02:45
created

ProductsServiceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 14
c 1
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A getById_WithValidId_ValidResponse() 0 15 1
1
<?php
2
3
namespace Dolibarr\Client\Tests\Service;
4
5
use Dolibarr\Client\Domain\Product\Product;
6
use Dolibarr\Client\Domain\Product\ProductId;
7
use Dolibarr\Client\Service\ProductsService;
8
9
/**
10
 * @package Dolibarr\Client\Tests\Service
11
 */
12
final class ProductsServiceTest extends ServiceTest
13
{
14
    /**
15
     * @var ProductsService()
16
     */
17
    private $service;
18
19
    /**
20
     * Setup the service.
21
     */
22
    protected function setUp()
23
    {
24
        parent::setUp();
25
        $this->service = new ProductsService($this->mockClient(), $this->serializer());
26
    }
27
    /**
28
     * @test
29
     */
30
    public function getById_WithValidId_ValidResponse()
31
    {
32
        $this->mockClient()
33
            ->expects($this->once())
34
            ->method('get')
35
            ->with('products/121')
36
            ->willReturn($this->buildResponse('Products/getById'));
37
38
        $product = $this->service->getById(new ProductId(121));
39
40
        $this->assertInstanceOf(Product::class, $product);
41
42
        $this->assertEquals('test', $product->getLabel());
43
        $this->assertEquals(121, $product->getId());
44
        $this->assertEquals('86768795768484', $product->getBarcode());
45
    }
46
}
47