Completed
Pull Request — master (#2)
by Kevin
01:28
created

DBALObjectRepositoryTest::creates_object()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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());
25
26
        $this->assertCount(4, \iterator_to_array($repository));
27
        $this->assertCount(4, $repository);
28
    }
29
30
    /**
31
     * @test
32
     */
33 View Code Duplication
    public function creates_object(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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