1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DNADesign\ElementalUserForms\Tests; |
4
|
|
|
|
5
|
|
|
use DNADesign\Elemental\Models\BaseElement; |
6
|
|
|
use SilverStripe\Dev\FunctionalTest; |
7
|
|
|
use SilverStripe\Dev\TestOnly; |
8
|
|
|
use SilverStripe\Forms\FieldList; |
9
|
|
|
use SilverStripe\Forms\Form; |
10
|
|
|
use SilverStripe\Forms\FormAction; |
11
|
|
|
use SilverStripe\Forms\TextField; |
12
|
|
|
use DNADesign\Elemental\Controllers\ElementController; |
13
|
|
|
use DNADesign\Elemental\Models\ElementalArea; |
14
|
|
|
use DNADesign\Elemental\Tests\ElementControllerTest\TestElement; |
|
|
|
|
15
|
|
|
use DNADesign\Elemental\Tests\ElementControllerTest\TestPage; |
|
|
|
|
16
|
|
|
use SilverStripe\Versioned\Versioned; |
17
|
|
|
|
18
|
|
|
class ElementFormControllerTest extends FunctionalTest |
19
|
|
|
{ |
20
|
|
|
protected static $fixture_file = 'ElementFormTest.yml'; |
21
|
|
|
|
22
|
|
|
protected static $use_draft_site = true; |
23
|
|
|
|
24
|
|
|
protected static $extra_dataobjects = array( |
25
|
|
|
TestPage::class, |
26
|
|
|
TestElement::class |
27
|
|
|
); |
28
|
|
|
|
29
|
|
|
protected function setUp() |
30
|
|
|
{ |
31
|
|
|
Versioned::set_stage(Versioned::DRAFT); |
32
|
|
|
parent::setUp(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testElementFormRendering() |
36
|
|
|
{ |
37
|
|
|
$this->logInWithPermission('ADMIN'); |
38
|
|
|
$page = $this->objFromFixture(TestPage::class, 'page1'); |
39
|
|
|
|
40
|
|
|
$element = $this->objFromFixture(TestElement::class, 'element1'); |
41
|
|
|
|
42
|
|
|
$response = $this->get($page->URLSegment); |
43
|
|
|
$formAction = sprintf('%s/element/%d/Form', $page->URLSegment, $element->ID); |
44
|
|
|
|
45
|
|
|
$this->assertContains( |
46
|
|
|
$formAction, |
47
|
|
|
$response->getBody(), |
48
|
|
|
'Element forms are rendered through ElementalArea templates' |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testElementFormSubmission() |
53
|
|
|
{ |
54
|
|
|
$this->logInWithPermission('ADMIN'); |
55
|
|
|
$page = $this->objFromFixture(TestPage::class, 'page1'); |
56
|
|
|
|
57
|
|
|
$element = $this->objFromFixture(TestElement::class, 'element1'); |
58
|
|
|
|
59
|
|
|
$response = $this->get($page->URLSegment); |
|
|
|
|
60
|
|
|
$response = $this->submitForm('Form_Form', null, array('TestValue' => 'Updated')); |
61
|
|
|
|
62
|
|
|
$this->assertContains( |
63
|
|
|
'TestValue: Updated', |
64
|
|
|
$response->getBody(), |
65
|
|
|
'Form values are submitted to correct element form' |
66
|
|
|
); |
67
|
|
|
$this->assertContains( |
68
|
|
|
sprintf('Element ID: %d', $element->ID), |
69
|
|
|
$response->getBody(), |
70
|
|
|
'Element form acts on correct element, as identified in the URL' |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths