Skip to content

Commit

Permalink
Merge pull request #19 from tractorcow/pulls/fix-tests
Browse files Browse the repository at this point in the history
BUG Fix travis / unit tests
  • Loading branch information
Damian Mooyman committed Mar 24, 2015
2 parents 4478e61 + c7b211e commit 747a801
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -10,12 +10,12 @@ 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
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss

script:
- phpunit userforms/tests/
- vendor/bin/phpunit spamprotection/tests/
3 changes: 3 additions & 0 deletions composer.json
Expand Up @@ -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"
Expand Down
21 changes: 13 additions & 8 deletions tests/FormSpamProtectionExtensionTest.php
Expand Up @@ -6,6 +6,11 @@
class FormSpamProtectionExtensionTest extends SapphireTest {

protected $usesDatabase = false;

/**
* @var Form
*/
protected $form = null;

public function setUp() {
parent::setUp();
Expand All @@ -16,6 +21,7 @@ public function setUp() {
new TextField('URL')
), new FieldList()
);
$this->form->disableSecurityToken();
}

public function testEnableSpamProtection() {
Expand All @@ -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());
}

Expand Down Expand Up @@ -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) {}
Expand Down

0 comments on commit 747a801

Please sign in to comment.