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

LazyCustomerLoaderSpec::it_is_choice_loader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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