mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
Merge pull request #19 from tractorcow/pulls/fix-tests
BUG Fix travis / unit tests
This commit is contained in:
commit
747a801ba5
@ -10,7 +10,7 @@ env:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.4
|
- php: 5.4
|
||||||
env: DB=MYSQL CORE_RELEASE=master
|
env: DB=MYSQL CORE_RELEASE=3
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||||
@ -18,4 +18,4 @@ before_script:
|
|||||||
- cd ~/builds/ss
|
- cd ~/builds/ss
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpunit userforms/tests/
|
- vendor/bin/phpunit spamprotection/tests/
|
@ -13,6 +13,9 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "~3.1"
|
"silverstripe/framework": "~3.1"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/PHPUnit": "~3.7@stable"
|
||||||
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.0.x-dev"
|
"dev-master": "2.0.x-dev"
|
||||||
|
@ -7,6 +7,11 @@ class FormSpamProtectionExtensionTest extends SapphireTest {
|
|||||||
|
|
||||||
protected $usesDatabase = false;
|
protected $usesDatabase = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Form
|
||||||
|
*/
|
||||||
|
protected $form = null;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@ -16,6 +21,7 @@ class FormSpamProtectionExtensionTest extends SapphireTest {
|
|||||||
new TextField('URL')
|
new TextField('URL')
|
||||||
), new FieldList()
|
), new FieldList()
|
||||||
);
|
);
|
||||||
|
$this->form->disableSecurityToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEnableSpamProtection() {
|
public function testEnableSpamProtection() {
|
||||||
@ -36,12 +42,12 @@ class FormSpamProtectionExtensionTest extends SapphireTest {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals('Bar', $form->Fields()->fieldByName('Captcha')->Title());
|
$this->assertEquals('Bar', $form->Fields()->fieldByName('Captcha')->Title());
|
||||||
|
}
|
||||||
|
|
||||||
$protector = new FormSpamProtectionExtensionTest_BarProtector();
|
public function testEnableSpamProtectionCustomTitle() {
|
||||||
$protector->title = "Baz";
|
|
||||||
|
|
||||||
$form = $this->form->enableSpamProtection(array(
|
$form = $this->form->enableSpamProtection(array(
|
||||||
'protector' => $protector
|
'protector' => 'FormSpamProtectionExtensionTest_BarProtector',
|
||||||
|
'title' => 'Baz',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals('Baz', $form->Fields()->fieldByName('Captcha')->Title());
|
$this->assertEquals('Baz', $form->Fields()->fieldByName('Captcha')->Title());
|
||||||
@ -106,10 +112,9 @@ class FormSpamProtectionExtensionTest_BazProtector implements SpamProtector, Tes
|
|||||||
*/
|
*/
|
||||||
class FormSpamProtectionExtensionTest_BarProtector implements SpamProtector, TestOnly {
|
class FormSpamProtectionExtensionTest_BarProtector implements SpamProtector, TestOnly {
|
||||||
|
|
||||||
public $title = 'Bar';
|
|
||||||
|
|
||||||
public function getFormField($name = null, $title = null, $value = null) {
|
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) {}
|
public function setFieldMapping($fieldMapping) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user