TestHelper::addSentEmails()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 1
Metric Value
cc 3
eloc 10
c 4
b 1
f 1
nc 2
nop 2
dl 0
loc 14
rs 9.9332
1
<?php
2
3
namespace Azine\EmailBundle\Tests;
4
5
use Azine\EmailBundle\Entity\SentEmail;
6
use Azine\EmailBundle\Services\AzineTemplateProvider;
7
use Doctrine\ORM\EntityManager;
8
9
class TestHelper
10
{
11
    const TEST_EMAIL = '[email protected]';
12
    const TEST_TOKEN = 'test_token';
13
14
    /**
15
     * @param EntityManager $manager
16
     * @param int           $count
17
     */
18
    public static function addSentEmails(EntityManager $manager, $count = 1)
19
    {
20
        while ($count > 0) {
21
            $sentEmail = new SentEmail();
22
            $sentEmail->setRecipients(array(self::TEST_EMAIL));
23
            $sentEmail->setSent(new \DateTime('2 weeks ago'));
24
            $sentEmail->setTemplate(AzineTemplateProvider::NEWSLETTER_TEMPLATE);
25
            $sentEmail->setVariables(array());
26
            $sentEmail->setToken(1 == $count ? self::TEST_TOKEN : self::TEST_TOKEN.$count);
27
            $manager->persist($sentEmail);
28
29
            --$count;
30
        }
31
        $manager->flush();
32
    }
33
}
34