FIX Update EmailRecipient to look in root directory for templates, optionally, fix other tests

This commit is contained in:
Robbie Averill 2017-08-16 11:57:50 +12:00
parent 011c2683a6
commit 1bd0b0c138
5 changed files with 16 additions and 4 deletions

View File

@ -20,7 +20,7 @@ before_script:
# Install composer dependencies
- composer install --prefer-dist
- composer require --prefer-dist --no-update silverstripe/framework:4.0.x-dev silverstripe/cms:4.0.x-dev silverstripe/admin:1.0.x-dev silverstripe/versioned:1.0.x-dev
- composer require --prefer-dist --no-update silverstripe/framework:4.0.x-dev silverstripe/cms:4.0.x-dev silverstripe/admin:1.0.x-dev silverstripe/versioned:1.0.x-dev silverstripe-themes/simple:~3.2
- composer update
script:

View File

@ -521,7 +521,12 @@ class EmailRecipient extends DataObject
$finder = new FileFinder();
$finder->setOption('name_regex', '/^.*\.ss$/');
$found = $finder->find(BASE_PATH . '/' . UserDefinedForm::config()->get('email_template_directory'));
$templateDirectory = UserDefinedForm::config()->get('email_template_directory');
// Handle cases where "userforms" might not be the base module directory, e.g. in a Travis build
if (!file_exists($templateDirectory) && substr($templateDirectory, 0, 10) === 'userforms/') {
$templateDirectory = substr($templateDirectory, 10);
}
$found = $finder->find(BASE_PATH . '/' . $templateDirectory);
foreach ($found as $key => $value) {
$template = pathinfo($value);

View File

@ -9,7 +9,7 @@ use SilverStripe\UserForms\Form\UserForm;
class UserFormTest extends SapphireTest
{
protected static $fixture_file = 'userforms/tests/Model/UserDefinedFormTest.yml';
protected static $fixture_file = '../Model/UserDefinedFormTest.yml';
/**
* Tests that a form will not generate empty pages

View File

@ -15,17 +15,24 @@ use SilverStripe\UserForms\Model\Submission\SubmittedFormField;
use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\UserForms\Model\UserDefinedFormController;
use SilverStripe\View\ArrayData;
use SilverStripe\View\SSViewer;
/**
* @package userforms
*/
class UserDefinedFormControllerTest extends FunctionalTest
{
protected static $fixture_file = 'UserDefinedFormTest.yml';
protected static $use_draft_site = true;
protected function setUp()
{
parent::setUp();
Config::modify()->set(SSViewer::class, 'themes', ['simple', '$default']);
}
public function testProcess()
{
$form = $this->setupFormFrontend();