Passed
Pull Request — master (#123)
by
unknown
05:44 queued 01:27
created

MailRepositoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canFindAllWithPid() 0 14 2
A setUp() 0 10 1
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Tests\Functional\Repository;
14
15
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
16
use Kitodo\Dlf\Domain\Repository\MailRepository;
17
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
18
19
class MailRepositoryTest extends FunctionalTestCase
20
{
21
    /**
22
     * @var MailRepository
23
     */
24
    protected $mailRepository;
25
26
    public function setUp(): void
27
    {
28
        parent::setUp();
29
30
        $this->mailRepository = $this->initializeRepository(
31
            MailRepository::class,
32
            20000
33
        );
34
35
        $this->importCSVDataSet(__DIR__ . '/../../Fixtures/Repository/mail.csv');
36
    }
37
38
    /**
39
     * @test
40
     * @group find
41
     */
42
    public function canFindAllWithPid(): void
43
    {
44
        $mails = $this->mailRepository->findAllWithPid(30000);
45
        self::assertNotNull($mails);
46
        self::assertInstanceOf(QueryResult::class, $mails);
47
48
        $mailByLabel = [];
49
        foreach ($mails as $mail) {
50
            $mailByLabel[$mail->getLabel()] = $mail;
51
        }
52
53
        self::assertEquals(2, $mails->count());
54
        self::assertArrayHasKey('Mail-Label-1', $mailByLabel);
55
        self::assertArrayHasKey('Mail-Label-2', $mailByLabel);
56
    }
57
}
58