Completed
Push — 2.5 ( c214a5 )
by Garion
03:54
created
tests/Tasks/PopulateThemeSampleDataTaskTest.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,50 +10,50 @@
 block discarded – undo
10 10
 
11 11
 class PopulateThemeSampleDataTaskTest extends SapphireTest
12 12
 {
13
-    protected $usesDatabase = true;
14
-
15
-    /**
16
-     * Ensure that the "contact" user form is only created once
17
-     */
18
-    public function testOnlyCreateContactFormOnce()
19
-    {
20
-        if (!class_exists(UserDefinedForm::class)) {
21
-            $this->markTestSkipped('This test requires the userforms module to be installed');
22
-        }
23
-
24
-        $createdMessage = 'Created "contact" UserDefinedForm';
25
-
26
-        $task = new PopulateThemeSampleDataTask;
27
-
28
-        // Run the task
29
-        $this->assertContains($createdMessage, $this->bufferedTask($task));
30
-
31
-        // Run a second time
32
-        $this->assertNotContains($createdMessage, $this->bufferedTask($task));
33
-
34
-        // Change the page name
35
-        $form = UserDefinedForm::get()->filter('URLSegment', 'contact')->first();
36
-        $form->URLSegment = 'testing';
37
-        $form->write();
38
-
39
-        // Ensure the old version is still detected in draft, so not recreated
40
-        $this->assertNotContains($createdMessage, $this->bufferedTask($task));
41
-
42
-        // Delete the page, then ensure it's recreated again (DataObject::delete will remove staged versions)
43
-        $form->delete();
44
-        $this->assertContains($createdMessage, $this->bufferedTask($task));
45
-    }
46
-
47
-    /**
48
-     * Run a BuildTask while buffering its output, and return the result
49
-     *
50
-     * @param  BuildTask $task
51
-     * @return string
52
-     */
53
-    protected function bufferedTask(BuildTask $task)
54
-    {
55
-        ob_start();
56
-        $task->run(new HTTPRequest('GET', '/'));
57
-        return ob_get_clean();
58
-    }
13
+	protected $usesDatabase = true;
14
+
15
+	/**
16
+	 * Ensure that the "contact" user form is only created once
17
+	 */
18
+	public function testOnlyCreateContactFormOnce()
19
+	{
20
+		if (!class_exists(UserDefinedForm::class)) {
21
+			$this->markTestSkipped('This test requires the userforms module to be installed');
22
+		}
23
+
24
+		$createdMessage = 'Created "contact" UserDefinedForm';
25
+
26
+		$task = new PopulateThemeSampleDataTask;
27
+
28
+		// Run the task
29
+		$this->assertContains($createdMessage, $this->bufferedTask($task));
30
+
31
+		// Run a second time
32
+		$this->assertNotContains($createdMessage, $this->bufferedTask($task));
33
+
34
+		// Change the page name
35
+		$form = UserDefinedForm::get()->filter('URLSegment', 'contact')->first();
36
+		$form->URLSegment = 'testing';
37
+		$form->write();
38
+
39
+		// Ensure the old version is still detected in draft, so not recreated
40
+		$this->assertNotContains($createdMessage, $this->bufferedTask($task));
41
+
42
+		// Delete the page, then ensure it's recreated again (DataObject::delete will remove staged versions)
43
+		$form->delete();
44
+		$this->assertContains($createdMessage, $this->bufferedTask($task));
45
+	}
46
+
47
+	/**
48
+	 * Run a BuildTask while buffering its output, and return the result
49
+	 *
50
+	 * @param  BuildTask $task
51
+	 * @return string
52
+	 */
53
+	protected function bufferedTask(BuildTask $task)
54
+	{
55
+		ob_start();
56
+		$task->run(new HTTPRequest('GET', '/'));
57
+		return ob_get_clean();
58
+	}
59 59
 }
Please login to merge, or discard this patch.
src/Tasks/PopulateThemeSampleDataTask.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -17,136 +17,136 @@
 block discarded – undo
17 17
  */
18 18
 class PopulateThemeSampleDataTask extends BuildTask
19 19
 {
20
-    protected $title = 'Populate sample data for theme demo';
21
-
22
-    protected $description = 'Populates some sample data for showcasing the functionality of the '
23
-        . 'starter and Wātea themes';
24
-
25
-    /**
26
-     * A series of method calls to create sample data
27
-     *
28
-     * @param HTTPRequest $request
29
-     */
30
-    public function run($request)
31
-    {
32
-        if (!class_exists(UserDefinedForm::class)) {
33
-            return;
34
-        }
35
-        $this->handleContactForm();
36
-    }
37
-
38
-    /**
39
-     * Decide whether to create a contact user defined form, and call it to be be created if so
40
-     *
41
-     * @return $this
42
-     */
43
-    protected function handleContactForm()
44
-    {
45
-        if (!$this->getContactFormExists()) {
46
-            $this->createContactForm();
47
-        }
48
-        return $this;
49
-    }
50
-
51
-    /**
52
-     * Determine whether a "contact us" userform exists yet
53
-     *
54
-     * @return bool
55
-     */
56
-    protected function getContactFormExists()
57
-    {
58
-        $exists = false;
59
-        foreach (UserDefinedForm::get()->column('ID') as $formId) {
60
-            $count = Versioned::get_all_versions(UserDefinedForm::class, $formId)
61
-                ->filter('URLSegment', 'contact')
62
-                ->count();
63
-
64
-            if ($count >= 1) {
65
-                $exists = true;
66
-                break;
67
-            }
68
-        }
69
-        return $exists;
70
-    }
71
-
72
-    /**
73
-     * Create a "contact us" userform. Please note that this form does not have any recipients by default, so
74
-     * no emails will be sent. To add recipients - edit the page in the CMS and add a recipient via the "Recipients"
75
-     * tab.
76
-     *
77
-     * @return $this
78
-     */
79
-    protected function createContactForm()
80
-    {
81
-        $form = UserDefinedForm::create(array(
82
-            'Title' => 'Contact',
83
-            'URLSegment' => 'contact',
84
-            'Content' => '<p>$UserDefinedForm</p>',
85
-            'SubmitButtonText' => 'Submit',
86
-            'ClearButtonText' => 'Clear',
87
-            'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>",
88
-            'EnableLiveValidation' => true
89
-        ));
90
-
91
-        $form->write();
92
-
93
-        // Add form fields
94
-        $fields = array(
95
-            EditableFormStep::create([
96
-                'Title' => _t(
97
-                    'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST',
98
-                    'First Page'
99
-                )
100
-            ]),
101
-            EditableTextField::create([
102
-                'Title' => 'Name',
103
-                'Required' => true,
104
-                'RightTitle' => 'Please enter your first and last name'
105
-            ]),
106
-            EditableEmailField::create([
107
-                'Title' => Email::class,
108
-                'Required' => true,
109
-                'Placeholder' => '[email protected]'
110
-            ]),
111
-            EditableTextField::create([
112
-                'Title' => 'Subject'
113
-            ]),
114
-            EditableTextField::create([
115
-                'Title' => 'Message',
116
-                'Required' => true,
117
-                'Rows' => 5
118
-            ])
119
-        );
120
-
121
-        foreach ($fields as $field) {
122
-            $field->write();
123
-            $form->Fields()->add($field);
124
-            $field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
125
-        }
126
-
127
-        $form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
128
-        $form->flushCache();
129
-
130
-        $this->output(' + Created "contact" UserDefinedForm page');
131
-
132
-        return $this;
133
-    }
134
-
135
-    /**
136
-     * Output a message either to the console or browser
137
-     *
138
-     * @param  string $message
139
-     * @return $this
140
-     */
141
-    protected function output($message)
142
-    {
143
-        if (Director::is_cli()) {
144
-            $message .= PHP_EOL;
145
-        } else {
146
-            $message = sprintf('<p>%s</p>', $message);
147
-        }
148
-        echo $message;
149
-
150
-        return $this;
151
-    }
20
+	protected $title = 'Populate sample data for theme demo';
21
+
22
+	protected $description = 'Populates some sample data for showcasing the functionality of the '
23
+		. 'starter and Wātea themes';
24
+
25
+	/**
26
+	 * A series of method calls to create sample data
27
+	 *
28
+	 * @param HTTPRequest $request
29
+	 */
30
+	public function run($request)
31
+	{
32
+		if (!class_exists(UserDefinedForm::class)) {
33
+			return;
34
+		}
35
+		$this->handleContactForm();
36
+	}
37
+
38
+	/**
39
+	 * Decide whether to create a contact user defined form, and call it to be be created if so
40
+	 *
41
+	 * @return $this
42
+	 */
43
+	protected function handleContactForm()
44
+	{
45
+		if (!$this->getContactFormExists()) {
46
+			$this->createContactForm();
47
+		}
48
+		return $this;
49
+	}
50
+
51
+	/**
52
+	 * Determine whether a "contact us" userform exists yet
53
+	 *
54
+	 * @return bool
55
+	 */
56
+	protected function getContactFormExists()
57
+	{
58
+		$exists = false;
59
+		foreach (UserDefinedForm::get()->column('ID') as $formId) {
60
+			$count = Versioned::get_all_versions(UserDefinedForm::class, $formId)
61
+				->filter('URLSegment', 'contact')
62
+				->count();
63
+
64
+			if ($count >= 1) {
65
+				$exists = true;
66
+				break;
67
+			}
68
+		}
69
+		return $exists;
70
+	}
71
+
72
+	/**
73
+	 * Create a "contact us" userform. Please note that this form does not have any recipients by default, so
74
+	 * no emails will be sent. To add recipients - edit the page in the CMS and add a recipient via the "Recipients"
75
+	 * tab.
76
+	 *
77
+	 * @return $this
78
+	 */
79
+	protected function createContactForm()
80
+	{
81
+		$form = UserDefinedForm::create(array(
82
+			'Title' => 'Contact',
83
+			'URLSegment' => 'contact',
84
+			'Content' => '<p>$UserDefinedForm</p>',
85
+			'SubmitButtonText' => 'Submit',
86
+			'ClearButtonText' => 'Clear',
87
+			'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>",
88
+			'EnableLiveValidation' => true
89
+		));
90
+
91
+		$form->write();
92
+
93
+		// Add form fields
94
+		$fields = array(
95
+			EditableFormStep::create([
96
+				'Title' => _t(
97
+					'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST',
98
+					'First Page'
99
+				)
100
+			]),
101
+			EditableTextField::create([
102
+				'Title' => 'Name',
103
+				'Required' => true,
104
+				'RightTitle' => 'Please enter your first and last name'
105
+			]),
106
+			EditableEmailField::create([
107
+				'Title' => Email::class,
108
+				'Required' => true,
109
+				'Placeholder' => '[email protected]'
110
+			]),
111
+			EditableTextField::create([
112
+				'Title' => 'Subject'
113
+			]),
114
+			EditableTextField::create([
115
+				'Title' => 'Message',
116
+				'Required' => true,
117
+				'Rows' => 5
118
+			])
119
+		);
120
+
121
+		foreach ($fields as $field) {
122
+			$field->write();
123
+			$form->Fields()->add($field);
124
+			$field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
125
+		}
126
+
127
+		$form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
128
+		$form->flushCache();
129
+
130
+		$this->output(' + Created "contact" UserDefinedForm page');
131
+
132
+		return $this;
133
+	}
134
+
135
+	/**
136
+	 * Output a message either to the console or browser
137
+	 *
138
+	 * @param  string $message
139
+	 * @return $this
140
+	 */
141
+	protected function output($message)
142
+	{
143
+		if (Director::is_cli()) {
144
+			$message .= PHP_EOL;
145
+		} else {
146
+			$message = sprintf('<p>%s</p>', $message);
147
+		}
148
+		echo $message;
149
+
150
+		return $this;
151
+	}
152 152
 }
Please login to merge, or discard this patch.
src/PageTypes/SitemapPageController.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -7,45 +7,45 @@
 block discarded – undo
7 7
 
8 8
 class SitemapPageController extends PageController
9 9
 {
10
-    private static $allowed_actions = [
11
-        'showpage',
12
-    ];
13
-
14
-    private static $url_handlers = [
15
-        'page/$ID' => 'showpage',
16
-    ];
17
-
18
-    public function showpage($request)
19
-    {
20
-        $id = (int) $request->param('ID');
21
-        if (!$id) {
22
-            return false;
23
-        }
24
-        $page = SiteTree::get()->byId($id);
25
-
26
-        // does the page exist?
27
-        if (!($page && $page->exists())) {
28
-            return $this->httpError(404);
29
-        }
30
-
31
-        // can the page be viewed?
32
-        if (!$page->canView()) {
33
-            return $this->httpError(403);
34
-        }
35
-
36
-        $viewer = $this->customise([
37
-            'IsAjax' => $request->isAjax(),
38
-            'SelectedPage' => $page,
39
-            'Children' => $page->Children(),
40
-        ]);
41
-
42
-        if ($request->isAjax()) {
43
-            return $viewer->renderWith([
44
-                'type' => 'Includes',
45
-                'SitemapNodeChildren'
46
-            ]);
47
-        }
48
-
49
-        return $viewer;
50
-    }
10
+	private static $allowed_actions = [
11
+		'showpage',
12
+	];
13
+
14
+	private static $url_handlers = [
15
+		'page/$ID' => 'showpage',
16
+	];
17
+
18
+	public function showpage($request)
19
+	{
20
+		$id = (int) $request->param('ID');
21
+		if (!$id) {
22
+			return false;
23
+		}
24
+		$page = SiteTree::get()->byId($id);
25
+
26
+		// does the page exist?
27
+		if (!($page && $page->exists())) {
28
+			return $this->httpError(404);
29
+		}
30
+
31
+		// can the page be viewed?
32
+		if (!$page->canView()) {
33
+			return $this->httpError(403);
34
+		}
35
+
36
+		$viewer = $this->customise([
37
+			'IsAjax' => $request->isAjax(),
38
+			'SelectedPage' => $page,
39
+			'Children' => $page->Children(),
40
+		]);
41
+
42
+		if ($request->isAjax()) {
43
+			return $viewer->renderWith([
44
+				'type' => 'Includes',
45
+				'SitemapNodeChildren'
46
+			]);
47
+		}
48
+
49
+		return $viewer;
50
+	}
51 51
 }
Please login to merge, or discard this patch.
src/Extensions/TaxonomyTermExtension.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
 class TaxonomyTermExtension extends DataExtension
11 11
 {
12 12
 
13
-    private static $api_access = true;
13
+	private static $api_access = true;
14 14
 
15
-    private static $belongs_many_many = array(
16
-        'Pages' => BasePage::class
17
-    );
15
+	private static $belongs_many_many = array(
16
+		'Pages' => BasePage::class
17
+	);
18 18
 
19
-    public function updateCMSFields(FieldList $fields)
20
-    {
21
-        $pagesGridField = $fields->dataFieldByName('Pages');
22
-        if ($pagesGridField) {
23
-            $pagesGridField->getConfig()->removeComponentsByType(GridFieldAddNewButton::class);
24
-        }
25
-    }
19
+	public function updateCMSFields(FieldList $fields)
20
+	{
21
+		$pagesGridField = $fields->dataFieldByName('Pages');
22
+		if ($pagesGridField) {
23
+			$pagesGridField->getConfig()->removeComponentsByType(GridFieldAddNewButton::class);
24
+		}
25
+	}
26 26
 }
Please login to merge, or discard this patch.
src/Extensions/CwpSiteSummaryExtension.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -5,41 +5,41 @@
 block discarded – undo
5 5
  */
6 6
 class CwpSiteSummaryExtension extends Extension
7 7
 {
8
-    /**
9
-     * Updates the modules used for the version label by:
10
-     *  - Removing SS Framework
11
-     *  - Adding CWP
12
-     *  - Relabelling SS CMS
13
-     *
14
-     * @param array $modules
15
-     */
16
-    public function updateVersionModules(&$modules)
17
-    {
18
-        unset($modules['silverstripe/framework']);
19
-        $modules = ['cwp/cwp' => 'CWP'] + $modules;
20
-        $modules['silverstripe/cms'] = 'SilverStripe CMS';
21
-    }
8
+	/**
9
+	 * Updates the modules used for the version label by:
10
+	 *  - Removing SS Framework
11
+	 *  - Adding CWP
12
+	 *  - Relabelling SS CMS
13
+	 *
14
+	 * @param array $modules
15
+	 */
16
+	public function updateVersionModules(&$modules)
17
+	{
18
+		unset($modules['silverstripe/framework']);
19
+		$modules = ['cwp/cwp' => 'CWP'] + $modules;
20
+		$modules['silverstripe/cms'] = 'SilverStripe CMS';
21
+	}
22 22
 
23
-    /**
24
-     * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing
25
-     * filter options)
26
-     *
27
-     * @param GridFieldDropdownFilter $dropdownFilter
28
-     */
29
-    public function updateDropdownFilterOptions($dropdownFilter)
30
-    {
31
-        $dropdownFilter->removeFilterOption('supported');
32
-        $dropdownFilter->removeFilterOption('unsupported');
23
+	/**
24
+	 * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing
25
+	 * filter options)
26
+	 *
27
+	 * @param GridFieldDropdownFilter $dropdownFilter
28
+	 */
29
+	public function updateDropdownFilterOptions($dropdownFilter)
30
+	{
31
+		$dropdownFilter->removeFilterOption('supported');
32
+		$dropdownFilter->removeFilterOption('unsupported');
33 33
 
34
-        $dropdownFilter->addFilterOption(
35
-            'supported',
36
-            _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'),
37
-            ['Supported' => true]
38
-        );
39
-        $dropdownFilter->addFilterOption(
40
-            'unsupported',
41
-            _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'),
42
-            ['Supported' => false]
43
-        );
44
-    }
34
+		$dropdownFilter->addFilterOption(
35
+			'supported',
36
+			_t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'),
37
+			['Supported' => true]
38
+		);
39
+		$dropdownFilter->addFilterOption(
40
+			'unsupported',
41
+			_t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'),
42
+			['Supported' => false]
43
+		);
44
+	}
45 45
 }
Please login to merge, or discard this patch.
src/Extensions/MaintenanceProxyExtension.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@
 block discarded – undo
13 13
  */
14 14
 class MaintenanceProxyExtension extends Extension
15 15
 {
16
-    /**
17
-     * Configures required environment settings for Composer's use, applies to
18
-     * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in
19
-     * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer
20
-     * is created
21
-     */
22
-    public function onAfterBuild()
23
-    {
24
-        // Provide access for Composer's StreamContextFactory, since it creates its own stream context
25
-        if ($proxy = $this->getCwpProxy()) {
26
-            $_SERVER['CGI_HTTP_PROXY'] = $proxy;
27
-        }
28
-    }
16
+	/**
17
+	 * Configures required environment settings for Composer's use, applies to
18
+	 * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in
19
+	 * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer
20
+	 * is created
21
+	 */
22
+	public function onAfterBuild()
23
+	{
24
+		// Provide access for Composer's StreamContextFactory, since it creates its own stream context
25
+		if ($proxy = $this->getCwpProxy()) {
26
+			$_SERVER['CGI_HTTP_PROXY'] = $proxy;
27
+		}
28
+	}
29 29
 
30
-    /**
31
-     * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in
32
-     * their Guzzle clients
33
-     *
34
-     * @param array $options
35
-     */
36
-    public function updateClientOptions(&$options)
37
-    {
38
-        if ($proxy = $this->getCwpProxy()) {
39
-            $options['proxy'] = $proxy;
40
-        }
41
-    }
30
+	/**
31
+	 * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in
32
+	 * their Guzzle clients
33
+	 *
34
+	 * @param array $options
35
+	 */
36
+	public function updateClientOptions(&$options)
37
+	{
38
+		if ($proxy = $this->getCwpProxy()) {
39
+			$options['proxy'] = $proxy;
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234`
45
-     *
46
-     * @return string
47
-     */
48
-    protected function getCwpProxy()
49
-    {
50
-        if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) {
51
-            return '';
52
-        }
43
+	/**
44
+	 * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234`
45
+	 *
46
+	 * @return string
47
+	 */
48
+	protected function getCwpProxy()
49
+	{
50
+		if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) {
51
+			return '';
52
+		}
53 53
 
54
-        return sprintf(
55
-            'tcp://%s:%d',
56
-            Environment::getEnv('SS_OUTBOUND_PROXY'),
57
-            Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
58
-        );
59
-    }
54
+		return sprintf(
55
+			'tcp://%s:%d',
56
+			Environment::getEnv('SS_OUTBOUND_PROXY'),
57
+			Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
58
+		);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
tests/Report/CwpStatsReportTest.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@
 block discarded – undo
11 11
 
12 12
 class CwpStatsReportTest extends SapphireTest
13 13
 {
14
-    protected static $fixture_file = 'CwpStatsReportTest.yml';
15
-
16
-    protected function setUp()
17
-    {
18
-        Config::modify()->set(SiteTree::class, 'create_default_pages', false);
19
-
20
-        parent::setUp();
21
-    }
22
-
23
-    public function testCount()
24
-    {
25
-        // Publish all pages apart from page3.
26
-        $this->objFromFixture(Page::class, 'page1')->publishRecursive();
27
-        $this->objFromFixture(Page::class, 'page2')->publishRecursive();
28
-        $this->objFromFixture(Page::class, 'page3')->publishRecursive();
29
-
30
-        // Add page5s to a subsite, if the module is installed.
31
-        $page5s = $this->objFromFixture(Page::class, 'page5s');
32
-        if (class_exists(Subsite::class)) {
33
-            $subsite = Subsite::create();
34
-            $subsite->Title = 'subsite';
35
-            $subsite->write();
36
-
37
-            $page5s->SubsiteID = $subsite->ID;
38
-            $page5s->write();
39
-        }
40
-        $page5s->publishRecursive();
41
-
42
-        $report = CwpStatsReport::create();
43
-        $records = $report->sourceRecords([])->toArray();
44
-        $i = 0;
45
-        $this->assertEquals(4, $records[$i++]['Count'], 'Four pages in total, across locales, subsites, live only.');
46
-        if (class_exists(Subsite::class)) {
47
-            $this->assertEquals(3, $records[$i++]['Count'], 'Three pages in the main site, if subsites installed.');
48
-            $this->assertEquals(1, $records[$i++]['Count'], 'One page in the subsite, if subsites installed');
49
-        }
50
-        $this->assertEquals(1, $records[$i++]['Count'], 'One file in total.');
51
-    }
14
+	protected static $fixture_file = 'CwpStatsReportTest.yml';
15
+
16
+	protected function setUp()
17
+	{
18
+		Config::modify()->set(SiteTree::class, 'create_default_pages', false);
19
+
20
+		parent::setUp();
21
+	}
22
+
23
+	public function testCount()
24
+	{
25
+		// Publish all pages apart from page3.
26
+		$this->objFromFixture(Page::class, 'page1')->publishRecursive();
27
+		$this->objFromFixture(Page::class, 'page2')->publishRecursive();
28
+		$this->objFromFixture(Page::class, 'page3')->publishRecursive();
29
+
30
+		// Add page5s to a subsite, if the module is installed.
31
+		$page5s = $this->objFromFixture(Page::class, 'page5s');
32
+		if (class_exists(Subsite::class)) {
33
+			$subsite = Subsite::create();
34
+			$subsite->Title = 'subsite';
35
+			$subsite->write();
36
+
37
+			$page5s->SubsiteID = $subsite->ID;
38
+			$page5s->write();
39
+		}
40
+		$page5s->publishRecursive();
41
+
42
+		$report = CwpStatsReport::create();
43
+		$records = $report->sourceRecords([])->toArray();
44
+		$i = 0;
45
+		$this->assertEquals(4, $records[$i++]['Count'], 'Four pages in total, across locales, subsites, live only.');
46
+		if (class_exists(Subsite::class)) {
47
+			$this->assertEquals(3, $records[$i++]['Count'], 'Three pages in the main site, if subsites installed.');
48
+			$this->assertEquals(1, $records[$i++]['Count'], 'One page in the subsite, if subsites installed');
49
+		}
50
+		$this->assertEquals(1, $records[$i++]['Count'], 'One file in total.');
51
+	}
52 52
 }
Please login to merge, or discard this patch.
src/Extensions/CwpCommentingExtension.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@
 block discarded – undo
14 14
  */
15 15
 class CwpCommentingExtension extends Extension
16 16
 {
17
-    public function alterCommentForm(Form $form)
18
-    {
19
-        $fields = $form->Fields();
17
+	public function alterCommentForm(Form $form)
18
+	{
19
+		$fields = $form->Fields();
20 20
 
21
-        if ($emailField = $fields->dataFieldByName('Email')) {
22
-            $emailField
23
-                ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email'))
24
-                ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
25
-        }
21
+		if ($emailField = $fields->dataFieldByName('Email')) {
22
+			$emailField
23
+				->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email'))
24
+				->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
25
+		}
26 26
 
27
-        if ($urlField = $fields->dataFieldByName('URL')) {
28
-            $urlField
29
-                ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
30
-                ->setAttribute('placeholder', 'http://');
31
-        }
32
-    }
27
+		if ($urlField = $fields->dataFieldByName('URL')) {
28
+			$urlField
29
+				->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
30
+				->setAttribute('placeholder', 'http://');
31
+		}
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Model/RelatedPageLink.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,30 +8,30 @@
 block discarded – undo
8 8
 
9 9
 class RelatedPageLink extends DataObject
10 10
 {
11
-    private static $table_name = 'BasePage_RelatedPages';
11
+	private static $table_name = 'BasePage_RelatedPages';
12 12
 
13
-    private static $extensions = [
14
-        Versioned::class,
15
-    ];
13
+	private static $extensions = [
14
+		Versioned::class,
15
+	];
16 16
 
17
-    private static $db = [
18
-        'SortOrder' => 'Int',
19
-    ];
17
+	private static $db = [
18
+		'SortOrder' => 'Int',
19
+	];
20 20
 
21
-    /**
22
-     * For backwards compatibility these must match a traditional 'many_many' definition.
23
-     * This was BasePage.RelatedPages => BasePage
24
-     * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID
25
-     * excepting in the case where ${DefiningClass} === ${RelatedClass}
26
-     * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID".
27
-     *
28
-     * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
29
-     *
30
-     * @var array
31
-     * @config
32
-     */
33
-    private static $has_one = [
34
-        'BasePage' => BasePage::class,
35
-        'Child' => BasePage::class,
36
-    ];
21
+	/**
22
+	 * For backwards compatibility these must match a traditional 'many_many' definition.
23
+	 * This was BasePage.RelatedPages => BasePage
24
+	 * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID
25
+	 * excepting in the case where ${DefiningClass} === ${RelatedClass}
26
+	 * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID".
27
+	 *
28
+	 * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
29
+	 *
30
+	 * @var array
31
+	 * @config
32
+	 */
33
+	private static $has_one = [
34
+		'BasePage' => BasePage::class,
35
+		'Child' => BasePage::class,
36
+	];
37 37
 }
Please login to merge, or discard this patch.