Completed
Push — master ( 133170...772a04 )
by Dominik
06:01 queued 04:25
created

TestHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A addSentEmails() 0 15 3
1
<?php
2
namespace Azine\EmailBundle\Tests;
3
4
use Azine\EmailBundle\Entity\SentEmail;
5
use Azine\EmailBundle\Services\AzineTemplateProvider;
6
use Doctrine\ORM\EntityManager;
7
8
class TestHelper
9
{
10
    const TEST_EMAIL = '[email protected]';
11
    const TEST_TOKEN = 'test_token';
12
    /**
13
     * @param integer $count
14
     */
15
    public static function addSentEmails(EntityManager $manager, $count = 1)
16
    {
17
        while ($count > 0) {
18
            $sentEmail = new SentEmail();
19
            $sentEmail->setRecipients(array(self::TEST_EMAIL));
20
            $sentEmail->setSent(new \DateTime("2 weeks ago"));
21
            $sentEmail->setTemplate(AzineTemplateProvider::NEWSLETTER_TEMPLATE);
22
            $sentEmail->setVariables(array());
23
            $sentEmail->setToken($count == 1 ? self::TEST_TOKEN : self::TEST_TOKEN . $count);
24
            $manager->persist($sentEmail);
25
26
            $count--;
27
        }
28
        $manager->flush();
29
    }
30
}
31