DBALObjectRepositoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A can_iterate_and_count() 0 8 1
A creates_object() 0 8 1
1
<?php
2
3
namespace Zenstruck\Porpaginas\Tests\Doctrine\Repository;
4
5
use PHPUnit\Framework\TestCase;
6
use Zenstruck\Porpaginas\Tests\Doctrine\Fixtures\DBALObject;
7
use Zenstruck\Porpaginas\Tests\Doctrine\Fixtures\DBALObjectRepository;
8
use Zenstruck\Porpaginas\Tests\Doctrine\HasEntityManager;
9
10
/**
11
 * @author Kevin Bond <[email protected]>
12
 */
13
final class DBALObjectRepositoryTest extends TestCase
14
{
15
    use HasEntityManager;
16
17
    /**
18
     * @test
19
     */
20
    public function can_iterate_and_count(): void
21
    {
22
        $this->persistEntities(4);
23
24
        $repository = new DBALObjectRepository($this->em->getConnection());
0 ignored issues
show
Bug introduced by
The method getConnection() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        $repository = new DBALObjectRepository($this->em->/** @scrutinizer ignore-call */ getConnection());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
26
        $this->assertCount(4, \iterator_to_array($repository));
27
        $this->assertCount(4, $repository);
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function creates_object(): void
34
    {
35
        $this->persistEntities(1);
36
37
        $object = \iterator_to_array(new DBALObjectRepository($this->em->getConnection()))[0];
38
39
        $this->assertInstanceOf(DBALObject::class, $object);
40
        $this->assertSame('value 1', $object->value);
41
    }
42
}
43