Completed
Push — 2 ( e3bf7a...d29a5f )
by Maxime
23s queued 14s
created
tests/PageTypes/DatedUpdateHolderControllerTest.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -9,44 +9,44 @@
 block discarded – undo
9 9
 
10 10
 class DatedUpdateHolderControllerTest extends FunctionalTest
11 11
 {
12
-    protected static $fixture_file = 'EventHolderTest.yml';
12
+	protected static $fixture_file = 'EventHolderTest.yml';
13 13
 
14
-    protected static $use_draft_site = true;
14
+	protected static $use_draft_site = true;
15 15
 
16
-    protected function setUp(): void
17
-    {
18
-        parent::setUp();
16
+	protected function setUp(): void
17
+	{
18
+		parent::setUp();
19 19
 
20
-        // Note: this test requires the starter theme to be installed
21
-        Config::modify()->set(SSViewer::class, 'themes', ['starter', '$default']);
22
-        Config::modify()->set(SSViewer::class, 'theme', 'starter');
23
-    }
20
+		// Note: this test requires the starter theme to be installed
21
+		Config::modify()->set(SSViewer::class, 'themes', ['starter', '$default']);
22
+		Config::modify()->set(SSViewer::class, 'theme', 'starter');
23
+	}
24 24
 
25
-    public function testSettingDateFiltersInReverseOrderShowsMessage()
26
-    {
27
-        /** @var EventHolder $holder */
28
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
25
+	public function testSettingDateFiltersInReverseOrderShowsMessage()
26
+	{
27
+		/** @var EventHolder $holder */
28
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
29 29
 
30
-        $result = $this->get($holder->Link() . '?from=2018-01-10&to=2018-01-01');
30
+		$result = $this->get($holder->Link() . '?from=2018-01-10&to=2018-01-01');
31 31
 
32
-        $this->assertStringContainsString('Filter has been applied with the dates reversed', $result->getBody());
33
-    }
32
+		$this->assertStringContainsString('Filter has been applied with the dates reversed', $result->getBody());
33
+	}
34 34
 
35
-    public function testSettingFromButNotToDateShowsMessage()
36
-    {
37
-        /** @var EventHolder $holder */
38
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
35
+	public function testSettingFromButNotToDateShowsMessage()
36
+	{
37
+		/** @var EventHolder $holder */
38
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
39 39
 
40
-        $result = $this->get($holder->Link() . '?from=2018-01-10');
40
+		$result = $this->get($holder->Link() . '?from=2018-01-10');
41 41
 
42
-        $this->assertStringContainsString('Filtered by a single date', $result->getBody());
43
-    }
42
+		$this->assertStringContainsString('Filtered by a single date', $result->getBody());
43
+	}
44 44
 
45
-    public function testInvalidDateFormat()
46
-    {
47
-        /** @var EventHolder $holder */
48
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
49
-        $result = $this->get($holder->Link() . '?from=christmas&to=2018-01-10');
50
-        $this->assertStringContainsString(htmlentities('Dates must be in "y-MM-dd" format.'), $result->getBody());
51
-    }
45
+	public function testInvalidDateFormat()
46
+	{
47
+		/** @var EventHolder $holder */
48
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
49
+		$result = $this->get($holder->Link() . '?from=christmas&to=2018-01-10');
50
+		$this->assertStringContainsString(htmlentities('Dates must be in "y-MM-dd" format.'), $result->getBody());
51
+	}
52 52
 }
Please login to merge, or discard this patch.
tests/PageTypes/SitemapPageTest.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -9,27 +9,27 @@
 block discarded – undo
9 9
 
10 10
 class SitemapPageTest extends FunctionalTest
11 11
 {
12
-    protected static $fixture_file = 'SitemapPageTest.yml';
12
+	protected static $fixture_file = 'SitemapPageTest.yml';
13 13
 
14
-    protected static $use_draft_site = true;
14
+	protected static $use_draft_site = true;
15 15
 
16
-    protected function setUp(): void
17
-    {
18
-        parent::setUp();
16
+	protected function setUp(): void
17
+	{
18
+		parent::setUp();
19 19
 
20
-        Config::modify()->set(SSViewer::class, 'themes', ['starter', '$default']);
21
-        Config::modify()->set(SSViewer::class, 'theme', 'starter');
22
-    }
20
+		Config::modify()->set(SSViewer::class, 'themes', ['starter', '$default']);
21
+		Config::modify()->set(SSViewer::class, 'theme', 'starter');
22
+	}
23 23
 
24
-    /**
25
-     * Note: this test depends on the "starter" theme being installed and configured as default
26
-     */
27
-    public function testSitemapShowsNavigationTitleNotNormalTitle()
28
-    {
29
-        $response = $this->get('sitemap');
30
-        $parser = new CSSContentParser($response->getBody());
31
-        $elements = $parser->getBySelector('.sitemap li.first .sitemap-link');
32
-        $this->assertNotEmpty($elements);
33
-        $this->assertEquals('Top page nav 1', (string) $elements[0]);
34
-    }
24
+	/**
25
+	 * Note: this test depends on the "starter" theme being installed and configured as default
26
+	 */
27
+	public function testSitemapShowsNavigationTitleNotNormalTitle()
28
+	{
29
+		$response = $this->get('sitemap');
30
+		$parser = new CSSContentParser($response->getBody());
31
+		$elements = $parser->getBySelector('.sitemap li.first .sitemap-link');
32
+		$this->assertNotEmpty($elements);
33
+		$this->assertEquals('Top page nav 1', (string) $elements[0]);
34
+	}
35 35
 }
Please login to merge, or discard this patch.
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->assertStringContainsString($createdMessage, $this->bufferedTask($task));
30
-
31
-        // Run a second time
32
-        $this->assertStringNotContainsString($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->assertStringNotContainsString($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->assertStringContainsString($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->assertStringContainsString($createdMessage, $this->bufferedTask($task));
30
+
31
+		// Run a second time
32
+		$this->assertStringNotContainsString($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->assertStringNotContainsString($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->assertStringContainsString($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.
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(): void
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(): void
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.