Completed
Pull Request — master (#12)
by Matthew
20:12 queued 05:14
created
tests/Extensions/ManageableDataObjectExtensionTest.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -16,137 +16,137 @@
 block discarded – undo
16 16
 class ManageableDataObjectExtensionTest extends FunctionalTest
17 17
 {
18 18
 
19
-	/**
20
-	 * @var string
21
-	 */
22
-	protected static $fixture_file = '../fixtures.yml';
23
-
24
-	/**
25
-	 * @var array
26
-	 */
27
-	protected static $extra_dataobjects = [
28
-		SampleManageableDataObject::class,
29
-		SampleManageableObjectPage::class,
30
-	];
31
-
32
-	/**
33
-	 *
34
-	 */
35
-	public function setUp()
36
-	{
37
-		parent::setUp();
38
-		// Suppress themes
39
-		SSViewer::config()->update('theme_enabled', false);
40
-	}
41
-
42
-	/**
43
-	 *
44
-	 */
45
-	public function testAdd()
46
-	{
47
-		/** @var SampleManageableObjectPage $page */
48
-		$page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
49
-
50
-		$this->logInWithPermission('MDO_Create');
51
-		$response = $this->get($page->Link('add'));
52
-		$this->assertEquals(200, $response->getStatusCode());
53
-		$this->logOut();
54
-	}
55
-
56
-	/**
57
-	 * Ensure any current member is logged out
58
-	 */
59
-	public function logOut()
60
-	{
61
-		if ($member = Security::getCurrentUser()) {
62
-			Security::setCurrentUser(null);
63
-		}
64
-	}
65
-
66
-	/**
67
-	 *
68
-	 */
69
-	public function testEdit()
70
-	{
71
-		/** @var SampleManageableDataObject $object */
72
-		$object = $this->objFromFixture(SampleManageableDataObject::class, 'one');
73
-		/** @var SampleManageableObjectPage $page */
74
-		$page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
75
-
76
-		$this->logInWithPermission('MDO_Edit');
77
-		$response = $this->get(Controller::join_links(
78
-			$page->Link(),
79
-			'edit',
80
-			$object->ID
81
-		));
82
-		$this->assertEquals(200, $response->getStatusCode());
83
-		$this->logOut();
84
-
85
-		$response2 = $this->get('/SampleManageableObjectPageController/edit/' . 0);
86
-		$this->assertEquals(404, $response2->getStatusCode());
87
-	}
88
-
89
-	/**
90
-	 *
91
-	 */
92
-	public function testDelete()
93
-	{
94
-		/** @var SampleManageableObjectPage $page */
95
-		$page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
96
-
97
-		$newObject = SampleManageableDataObject::create();
98
-		$newObject->Title = 'Foo';
99
-		$newObject->write();
100
-
101
-		$id = $newObject->ID;
102
-
103
-		$this->logInWithPermission('MDO_Delete');
104
-
105
-		$response404 = $this->get(Controller::join_links(
106
-			$page->Link(),
107
-			'delete',
108
-			0
109
-		));
110
-		$this->assertEquals(404, $response404->getStatusCode());
111
-
112
-		$success = $this->get(Controller::join_links(
113
-			$page->Link(),
114
-			'edit',
115
-			$id
116
-		));
117
-		$this->assertEquals(200, $success->getStatusCode());
118
-		$this->assertNull(SampleManageableDataObject::get()->byID($id));
119
-
120
-		$this->logOut();
121
-	}
122
-
123
-	/**
124
-	 *
125
-	 */
126
-	public function testDoSaveObject()
127
-	{
128
-		/** @var SampleManageableObjectPage $page */
129
-		$page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
130
-
131
-		$this->logInWithPermission('MDO_Create');
132
-
133
-		$controller = SampleManageableObjectPageController::create(
134
-			$this->objFromFixture(SampleManageableObjectPage::class, 'one')
135
-		);
136
-		$form = $controller->Form();
137
-
138
-		$response = $this->get($page->Link('add'));
139
-		$this->assertEquals(200, $response->getStatusCode(), 'Submission successful');
140
-
141
-		$data = ['Title' => 'Foobar'];
142
-		$responseSubmission = $this->submitForm(
143
-			'ManageableDataObjectForm_Form',
144
-			'action_doSaveObject',
145
-			$data
146
-		);
147
-
148
-		$record = SampleManageableDataObject::get()->filter($data)->first();
149
-		$this->assertInstanceOf(SampleManageableDataObject::class, $record);
150
-		$this->assertTrue($record->exists());
151
-	}
19
+    /**
20
+     * @var string
21
+     */
22
+    protected static $fixture_file = '../fixtures.yml';
23
+
24
+    /**
25
+     * @var array
26
+     */
27
+    protected static $extra_dataobjects = [
28
+        SampleManageableDataObject::class,
29
+        SampleManageableObjectPage::class,
30
+    ];
31
+
32
+    /**
33
+     *
34
+     */
35
+    public function setUp()
36
+    {
37
+        parent::setUp();
38
+        // Suppress themes
39
+        SSViewer::config()->update('theme_enabled', false);
40
+    }
41
+
42
+    /**
43
+     *
44
+     */
45
+    public function testAdd()
46
+    {
47
+        /** @var SampleManageableObjectPage $page */
48
+        $page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
49
+
50
+        $this->logInWithPermission('MDO_Create');
51
+        $response = $this->get($page->Link('add'));
52
+        $this->assertEquals(200, $response->getStatusCode());
53
+        $this->logOut();
54
+    }
55
+
56
+    /**
57
+     * Ensure any current member is logged out
58
+     */
59
+    public function logOut()
60
+    {
61
+        if ($member = Security::getCurrentUser()) {
62
+            Security::setCurrentUser(null);
63
+        }
64
+    }
65
+
66
+    /**
67
+     *
68
+     */
69
+    public function testEdit()
70
+    {
71
+        /** @var SampleManageableDataObject $object */
72
+        $object = $this->objFromFixture(SampleManageableDataObject::class, 'one');
73
+        /** @var SampleManageableObjectPage $page */
74
+        $page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
75
+
76
+        $this->logInWithPermission('MDO_Edit');
77
+        $response = $this->get(Controller::join_links(
78
+            $page->Link(),
79
+            'edit',
80
+            $object->ID
81
+        ));
82
+        $this->assertEquals(200, $response->getStatusCode());
83
+        $this->logOut();
84
+
85
+        $response2 = $this->get('/SampleManageableObjectPageController/edit/' . 0);
86
+        $this->assertEquals(404, $response2->getStatusCode());
87
+    }
88
+
89
+    /**
90
+     *
91
+     */
92
+    public function testDelete()
93
+    {
94
+        /** @var SampleManageableObjectPage $page */
95
+        $page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
96
+
97
+        $newObject = SampleManageableDataObject::create();
98
+        $newObject->Title = 'Foo';
99
+        $newObject->write();
100
+
101
+        $id = $newObject->ID;
102
+
103
+        $this->logInWithPermission('MDO_Delete');
104
+
105
+        $response404 = $this->get(Controller::join_links(
106
+            $page->Link(),
107
+            'delete',
108
+            0
109
+        ));
110
+        $this->assertEquals(404, $response404->getStatusCode());
111
+
112
+        $success = $this->get(Controller::join_links(
113
+            $page->Link(),
114
+            'edit',
115
+            $id
116
+        ));
117
+        $this->assertEquals(200, $success->getStatusCode());
118
+        $this->assertNull(SampleManageableDataObject::get()->byID($id));
119
+
120
+        $this->logOut();
121
+    }
122
+
123
+    /**
124
+     *
125
+     */
126
+    public function testDoSaveObject()
127
+    {
128
+        /** @var SampleManageableObjectPage $page */
129
+        $page = $this->objFromFixture(SampleManageableObjectPage::class, 'one');
130
+
131
+        $this->logInWithPermission('MDO_Create');
132
+
133
+        $controller = SampleManageableObjectPageController::create(
134
+            $this->objFromFixture(SampleManageableObjectPage::class, 'one')
135
+        );
136
+        $form = $controller->Form();
137
+
138
+        $response = $this->get($page->Link('add'));
139
+        $this->assertEquals(200, $response->getStatusCode(), 'Submission successful');
140
+
141
+        $data = ['Title' => 'Foobar'];
142
+        $responseSubmission = $this->submitForm(
143
+            'ManageableDataObjectForm_Form',
144
+            'action_doSaveObject',
145
+            $data
146
+        );
147
+
148
+        $record = SampleManageableDataObject::get()->filter($data)->first();
149
+        $this->assertInstanceOf(SampleManageableDataObject::class, $record);
150
+        $this->assertTrue($record->exists());
151
+    }
152 152
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 		$this->assertEquals(200, $response->getStatusCode());
83 83
 		$this->logOut();
84 84
 
85
-		$response2 = $this->get('/SampleManageableObjectPageController/edit/' . 0);
85
+		$response2 = $this->get('/SampleManageableObjectPageController/edit/'.0);
86 86
 		$this->assertEquals(404, $response2->getStatusCode());
87 87
 	}
88 88
 
Please login to merge, or discard this patch.