diff --git a/.travis.yml b/.travis.yml index 3310b3a..712345f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: matrix: include: - php: 5.4 - env: DB=MYSQL CORE_RELEASE=master + env: DB=MYSQL CORE_RELEASE=3 before_script: - git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support @@ -18,4 +18,4 @@ before_script: - cd ~/builds/ss script: - - phpunit userforms/tests/ \ No newline at end of file + - vendor/bin/phpunit spamprotection/tests/ \ No newline at end of file diff --git a/composer.json b/composer.json index 81f1bfc..3a384f4 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,9 @@ "require": { "silverstripe/framework": "~3.1" }, + "require-dev": { + "phpunit/PHPUnit": "~3.7@stable" + }, "extra": { "branch-alias": { "dev-master": "2.0.x-dev" diff --git a/tests/FormSpamProtectionExtensionTest.php b/tests/FormSpamProtectionExtensionTest.php index 7292450..1e67874 100644 --- a/tests/FormSpamProtectionExtensionTest.php +++ b/tests/FormSpamProtectionExtensionTest.php @@ -6,6 +6,11 @@ class FormSpamProtectionExtensionTest extends SapphireTest { protected $usesDatabase = false; + + /** + * @var Form + */ + protected $form = null; public function setUp() { parent::setUp(); @@ -16,6 +21,7 @@ public function setUp() { new TextField('URL') ), new FieldList() ); + $this->form->disableSecurityToken(); } public function testEnableSpamProtection() { @@ -36,14 +42,14 @@ public function testEnableSpamProtectionCustomProtector() { )); $this->assertEquals('Bar', $form->Fields()->fieldByName('Captcha')->Title()); + } - $protector = new FormSpamProtectionExtensionTest_BarProtector(); - $protector->title = "Baz"; - + public function testEnableSpamProtectionCustomTitle() { $form = $this->form->enableSpamProtection(array( - 'protector' => $protector + 'protector' => 'FormSpamProtectionExtensionTest_BarProtector', + 'title' => 'Baz', )); - + $this->assertEquals('Baz', $form->Fields()->fieldByName('Captcha')->Title()); } @@ -106,10 +112,9 @@ public function setFieldMapping($fieldMapping) {} */ class FormSpamProtectionExtensionTest_BarProtector implements SpamProtector, TestOnly { - public $title = 'Bar'; - public function getFormField($name = null, $title = null, $value = null) { - return new TextField($name, $this->title, $value); + $title = $title ?: 'Bar'; + return new TextField($name, $title, $value); } public function setFieldMapping($fieldMapping) {}