Completed
Push — master ( 4a6357...521c8c )
by Franco
10s
created

tests/ContentReviewNotificationTest.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * @mixin PHPUnit_Framework_TestCase
5
 */
6
class ContentReviewNotificationTest extends SapphireTest
7
{
8
    /**
9
     * @var string
10
     */
11
    public static $fixture_file = 'contentreview/tests/ContentReviewTest.yml';
12
13
    public function setUp()
14
    {
15
        parent::setUp();
16
17
        // Hack to ensure only desired siteconfig is scaffolded
18
        $desiredID = $this->idFromFixture('SiteConfig', 'mysiteconfig');
19
        foreach (SiteConfig::get()->exclude('ID', $desiredID) as $config) {
20
            $config->delete();
21
        }
22
    }
23
24
    /**
25
     * @var array
26
     */
27
    protected $requiredExtensions = array(
28
        'SiteTree' => array('SiteTreeContentReview'),
29
        'Group' => array('ContentReviewOwner'),
30
        'Member' => array('ContentReviewOwner'),
31
        'CMSPageEditController' => array('ContentReviewCMSExtension'),
32
        'SiteConfig' => array('ContentReviewDefaultSettings'),
33
    );
34
35
    public function testContentReviewEmails()
36
    {
37
        SS_Datetime::set_mock_now('2010-02-24 12:00:00');
38
39
        /** @var Page|SiteTreeContentReview $childParentPage */
40
        $childParentPage = $this->objFromFixture('Page', 'contact');
41
        $childParentPage->NextReviewDate = '2010-02-23';
42
        $childParentPage->write();
0 ignored issues
show
The method write() does not seem to exist on object<SiteTreeContentReview>.

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...
43
44
        $task = new ContentReviewEmails();
45
        $task->run(new SS_HTTPRequest('GET', '/dev/tasks/ContentReviewEmails'));
46
47
        // Set template variables (as per variable case)
48
        $ToEmail = '[email protected]';
49
        $Subject = 'Please log in to review some content!';
50
        $PagesCount = 3;
51
        $ToFirstName = 'Test';
52
53
        $email = $this->findEmail($ToEmail, null, $Subject);
54
        $this->assertNotNull($email, "Email haven't been sent.");
0 ignored issues
show
The method assertNotNull() does not seem to exist on object<ContentReviewNotificationTest>.

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...
55
        $this->assertContains(
56
            "<h1>$Subject</h1><p>There are $PagesCount pages that are due for review today by you, $ToFirstName.</p><p>This email was sent to $ToEmail</p>",
57
            $email['htmlContent']
58
        );
59
        $this->assertContains('Staff', $email['htmlContent']);
60
        $this->assertContains('Contact Us', $email['htmlContent']);
61
        $this->assertContains('Contact Us Child', $email['htmlContent']);
62
63
        SS_Datetime::clear_mock_now();
64
    }
65
}
66