RADRepositorySpec   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 49
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 11 1
A it_should_be_a_rad_entity_repository() 0 4 1
A it_should_find_all_valid_entities() 0 6 1
A it_should_find_only_one_result_when_method_contains_One() 0 8 1
A it_should_throw_non_unique_result_exception_when_finding_one_entity_and_multiple_results_were_found() 0 7 1
1
<?php
2
3
namespace spec\Knp\RadBundle\tests\fixtures;
4
5
use PhpSpec\ObjectBehavior;
6
use Doctrine\ORM\NonUniqueResultException;
7
8
class RADRepositorySpec extends ObjectBehavior
9
{
10
    /**
11
     * @param Doctrine\ORM\EntityManager         $em
12
     * @param Doctrine\ORM\Mapping\ClassMetadata $class
13
     * @param Doctrine\ORM\QueryBuilder          $qb
14
     * @param Doctrine\ORM\AbstractQuery         $query
15
     */
16
    function let($em, $class, $qb, $query)
17
    {
18
        $em->createQueryBuilder()->willReturn($qb);
19
        $qb->select(\Prophecy\Argument::any())->willReturn($qb);
20
        $qb->from(\Prophecy\Argument::cetera())->willReturn($qb);
21
        $qb->where('rad.foo = bar')->willReturn($qb);
22
        $class->name = 'rad';
23
        $qb->getQuery()->willReturn($query);
24
25
        $this->beConstructedWith($em, $class);
26
    }
27
28
    function it_should_be_a_rad_entity_repository()
0 ignored issues
show
Coding Style introduced by
Method name "RADRepositorySpec::it_should_be_a_rad_entity_repository" is not in camel caps format
Loading history...
29
    {
30
        $this->shouldHaveType('Knp\RadBundle\Doctrine\EntityRepository');
31
    }
32
33
    function it_should_find_all_valid_entities($qb, $query)
0 ignored issues
show
Unused Code introduced by
The parameter $qb is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Method name "RADRepositorySpec::it_should_find_all_valid_entities" is not in camel caps format
Loading history...
34
    {
35
        $query->getResult()->willReturn(array('foo', 'bar'));
36
37
        $this->findValid()->shouldReturn(array('foo', 'bar'));
38
    }
39
40
    function it_should_find_only_one_result_when_method_contains_One($qb, $query)
0 ignored issues
show
Coding Style introduced by
Method name "RADRepositorySpec::it_should_find_only_one_result_when_method_contains_One" is not in camel caps format
Loading history...
41
    {
42
        $qb->where('rad.id = 1')->willReturn($qb);
43
        $query->getOneOrNullResult()->willReturn('foo');
44
        $query->getResult()->shouldNotBeCalled();
45
46
        $this->findOneValid(1)->shouldReturn('foo');
47
    }
48
49
    function it_should_throw_non_unique_result_exception_when_finding_one_entity_and_multiple_results_were_found($qb, $query)
0 ignored issues
show
Coding Style introduced by
Method name "RADRepositorySpec::it_should_throw_non_unique_result_exception_when_finding_one_entity_and_multiple_results_were_found" is not in camel caps format
Loading history...
50
    {
51
        $qb->where('rad.id = 1')->willReturn($qb);
52
        $query->getOneOrNullResult()->willThrow(new NonUniqueResultException);
53
54
        $this->shouldThrow(new NonUniqueResultException)->duringFindOneValid(1);
55
    }
56
}
57