create_WithData_ValidPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 15
rs 9.9
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Dolibarr\Client\Tests\Service;
4
5
use Dolibarr\Client\Domain\Proposal\ProposalProduct;
6
use Dolibarr\Client\Domain\Resource\ResourceId;
7
use Dolibarr\Client\Service\ProposalService;
8
9
final class ProposalServiceTest extends ServiceTest
10
{
11
    /**
12
     * @var ProposalService
13
     */
14
    private $service;
15
16
    /**
17
     * Setup the service.
18
     */
19
    protected function setUp()
20
    {
21
        parent::setUp();
22
        $this->service = new ProposalService($this->mockClient(), $this->serializer());
23
    }
24
25
    /**
26
     * @test
27
     *
28
     * @throws \Exception
29
     */
30
    public function create_WithData_ValidPayload()
31
    {
32
        $this->mockClient()
33
            ->expects($this->once())
34
            ->method("post")
35
            ->with("proposals/33/lines", $this->anything())
36
            ->willReturn($this->buildResponse('Proposals/addLine'));
37
38
        $proposalProduct = new ProposalProduct(2, 4);
39
        $proposalProduct->setVatRate(6);
40
        $proposalProduct->setUnitPrice(100);
41
        $proposalProduct->setDescription('Description');
42
        $proposalProduct->setDiscount(10);
43
44
        $this->service->addProduct(new ResourceId(33), $proposalProduct);
45
    }
46
}
47