Completed
Push — master ( b1c6ca...52cd2c )
by Kamil
77:57 queued 60:05
created

LazyCustomerLoaderSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 38
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_choice_loader() 0 4 1
A it_loads_customers_by_email() 0 15 1
A it_does_not_load_any_choices_available() 0 4 1
A it_provides_empty_array_choice_list() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace spec\Sylius\Bundle\AdminApiBundle\Form\ChoiceList\Loader;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Core\Model\CustomerInterface;
18
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
19
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
20
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
21
22
final class LazyCustomerLoaderSpec extends ObjectBehavior
23
{
24
    function let(CustomerRepositoryInterface $customerRepository): void
25
    {
26
        $this->beConstructedWith($customerRepository);
27
    }
28
29
    function it_is_choice_loader(): void
30
    {
31
        $this->shouldImplement(ChoiceLoaderInterface::class);
32
    }
33
34
    function it_loads_customers_by_email(
35
        CustomerRepositoryInterface $customerRepository,
36
        CustomerInterface $firstCustomer,
37
        CustomerInterface $secondCustomer
38
    ): void {
39
        $customerRepository
40
            ->findBy(['email' => ['[email protected]', '[email protected]']])
41
            ->willReturn([$firstCustomer, $secondCustomer])
42
        ;
43
44
        $this
45
            ->loadChoicesForValues(['[email protected]', '[email protected]'])
46
            ->shouldReturn([$firstCustomer, $secondCustomer])
47
        ;
48
    }
49
50
    function it_does_not_load_any_choices_available(): void
51
    {
52
        $this->loadValuesForChoices([])->shouldReturn([]);
53
    }
54
55
    function it_provides_empty_array_choice_list(): void
56
    {
57
        $this->loadChoiceList()->shouldBeAnInstanceOf(ArrayChoiceList::class);
58
    }
59
}
60