Skip to content

Commit

Permalink
FIX Mock akismet spam protector if installed, fixes broken integratio…
Browse files Browse the repository at this point in the history
…n tests
  • Loading branch information
robbieaverill committed Jun 15, 2018
1 parent eca3ac0 commit 788cb6e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/CommentingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace SilverStripe\Comments\Tests;

use SilverStripe\Akismet\AkismetSpamProtector;
use SilverStripe\Comments\Controllers\CommentingController;
use SilverStripe\Comments\Model\Comment;
use SilverStripe\Comments\Model\Comment\SecurityToken as CommentSecurityToken;
use SilverStripe\Comments\Tests\Stubs\CommentableItem;
use SilverStripe\Comments\Tests\CommentTestHelper;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Email\Email;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
Expand Down Expand Up @@ -48,6 +49,12 @@ protected function setUp()

// We will assert against explicit responses, unless handed otherwise in a test for redirects
$this->autoFollowRedirection = false;

// Mock Akismet if it's installed
if (class_exists(AkismetSpamProtector::class)) {
$akismetMock = $this->createMock(AkismetSpamProtector::class);
Injector::inst()->registerService($akismetMock, AkismetSpamProtector::class);
}
}

public function testCommentsFormUsePreview()
Expand Down

0 comments on commit 788cb6e

Please sign in to comment.