Completed
Pull Request — master (#27)
by Will
01:17
created
tests/CookieStoreTest.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,69 +10,69 @@
 block discarded – undo
10 10
 
11 11
 class CookieStoreTest extends AbstractTest
12 12
 {
13
-    protected function getStore()
14
-    {
15
-        $store = Injector::inst()->get(CookieStore::class);
16
-        $store->setKey(uniqid());
17
-        $store->open(TempFolder::getTempFolder(BASE_PATH).'/'.__CLASS__, 'SESSIONCOOKIE');
13
+	protected function getStore()
14
+	{
15
+		$store = Injector::inst()->get(CookieStore::class);
16
+		$store->setKey(uniqid());
17
+		$store->open(TempFolder::getTempFolder(BASE_PATH).'/'.__CLASS__, 'SESSIONCOOKIE');
18 18
 
19
-        return $store;
20
-    }
19
+		return $store;
20
+	}
21 21
 
22
-    public function testStoreLargeData()
23
-    {
24
-        $session = uniqid();
25
-        $store = $this->getStore();
22
+	public function testStoreLargeData()
23
+	{
24
+		$session = uniqid();
25
+		$store = $this->getStore();
26 26
 
27
-        // Test new session is blank
28
-        $result = $store->read($session);
29
-        $this->assertEmpty($result);
27
+		// Test new session is blank
28
+		$result = $store->read($session);
29
+		$this->assertEmpty($result);
30 30
 
31
-        // Save data against session
32
-        $data1 = array(
33
-            'Large' => str_repeat('A', 600),
34
-            'Content' => str_repeat('B', 600)
35
-        );
36
-        $store->write($session, serialize($data1));
37
-        $result = $store->read($session);
31
+		// Save data against session
32
+		$data1 = array(
33
+			'Large' => str_repeat('A', 600),
34
+			'Content' => str_repeat('B', 600)
35
+		);
36
+		$store->write($session, serialize($data1));
37
+		$result = $store->read($session);
38 38
 
39
-        // Cookies should not try to store data that large
40
-        $this->assertEmpty($result);
41
-    }
39
+		// Cookies should not try to store data that large
40
+		$this->assertEmpty($result);
41
+	}
42 42
 
43
-    /**
44
-     * Ensure that subsequent reads without the necessary write do not report data
45
-     */
46
-    public function testReadInvalidatesData()
47
-    {
48
-        $session = uniqid();
49
-        $store = $this->getStore();
43
+	/**
44
+	 * Ensure that subsequent reads without the necessary write do not report data
45
+	 */
46
+	public function testReadInvalidatesData()
47
+	{
48
+		$session = uniqid();
49
+		$store = $this->getStore();
50 50
 
51
-        // Test new session is blank
52
-        $result = $store->read($session);
53
-        $this->assertEmpty($result);
51
+		// Test new session is blank
52
+		$result = $store->read($session);
53
+		$this->assertEmpty($result);
54 54
 
55
-        // Save data against session
56
-        $data1 = array(
57
-            'Color' => 'red',
58
-            'Animal' => 'elephant'
59
-        );
60
-        $store->write($session, serialize($data1));
61
-        $result = $store->read($session);
62
-        $this->assertEquals($data1, unserialize($result));
55
+		// Save data against session
56
+		$data1 = array(
57
+			'Color' => 'red',
58
+			'Animal' => 'elephant'
59
+		);
60
+		$store->write($session, serialize($data1));
61
+		$result = $store->read($session);
62
+		$this->assertEquals($data1, unserialize($result));
63 63
 
64
-        // Since we have read the data into the result, the application could modify this content
65
-        // and be unable to write it back due to headers being sent. We should thus assume
66
-        // that subsequent reads without a successful write do not purport to have valid data
67
-        $data1['Color'] = 'blue';
68
-        $result = $store->read($session);
69
-        $this->assertEmpty($result);
64
+		// Since we have read the data into the result, the application could modify this content
65
+		// and be unable to write it back due to headers being sent. We should thus assume
66
+		// that subsequent reads without a successful write do not purport to have valid data
67
+		$data1['Color'] = 'blue';
68
+		$result = $store->read($session);
69
+		$this->assertEmpty($result);
70 70
 
71
-        // Check that writing to cookie fails after headers are sent and these results remain
72
-        // invalidated
73
-        TestCookieStore::$override_headers_sent = true;
74
-        $store->write($session, serialize($data1));
75
-        $result = $store->read($session);
76
-        $this->assertEmpty($result);
77
-    }
71
+		// Check that writing to cookie fails after headers are sent and these results remain
72
+		// invalidated
73
+		TestCookieStore::$override_headers_sent = true;
74
+		$store->write($session, serialize($data1));
75
+		$result = $store->read($session);
76
+		$this->assertEmpty($result);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
tests/DatabaseStoreTest.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 
8 8
 class DatabaseStoreTest extends AbstractTest
9 9
 {
10
-    protected function getStore()
11
-    {
12
-        $store = Injector::inst()->get(DatabaseStore::class);
13
-        $store->setKey(uniqid());
10
+	protected function getStore()
11
+	{
12
+		$store = Injector::inst()->get(DatabaseStore::class);
13
+		$store->setKey(uniqid());
14 14
 
15
-        return $store;
16
-    }
15
+		return $store;
16
+	}
17 17
 }
Please login to merge, or discard this patch.
tests/Store/TestCookieStore.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@
 block discarded – undo
9 9
 {
10 10
 
11 11
 
12
-    /**
13
-     * Override value of 'headers_sent' but only if running tests.
14
-     *
15
-     * Set to true or false, or null to not override
16
-     *
17
-     * @var string
18
-     */
19
-    public static $override_headers_sent = null;
12
+	/**
13
+	 * Override value of 'headers_sent' but only if running tests.
14
+	 *
15
+	 * Set to true or false, or null to not override
16
+	 *
17
+	 * @var string
18
+	 */
19
+	public static $override_headers_sent = null;
20 20
 
21
-    protected function canWrite()
22
-    {
23
-        if (self::$override_headers_sent !== null) {
24
-            return !self::$override_headers_sent;
25
-        }
21
+	protected function canWrite()
22
+	{
23
+		if (self::$override_headers_sent !== null) {
24
+			return !self::$override_headers_sent;
25
+		}
26 26
 
27
-        parent::canWrite();
28
-    }
27
+		parent::canWrite();
28
+	}
29 29
 }
Please login to merge, or discard this patch.
tests/AbstractTest.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -10,109 +10,109 @@
 block discarded – undo
10 10
 
11 11
 abstract class AbstractTest extends SapphireTest
12 12
 {
13
-    public function setUp()
14
-    {
15
-        parent::setUp();
16
-
17
-        TestCookieStore::$override_headers_sent = false;
18
-
19
-        Injector::nest();
20
-        Injector::inst()->registerService(
21
-            new TestCookieStore(),
22
-            CookieStore::class
23
-        );
24
-
25
-        DBDatetime::set_mock_now('2010-03-15 12:00:00');
26
-
27
-        if (get_class() === get_class($this)) {
28
-            $this->markTestSkipped("Skipping abstract test");
29
-            $this->skipTest = true;
30
-        }
31
-    }
32
-
33
-    public function tearDown()
34
-    {
35
-        Injector::unnest();
36
-        DBDatetime::clear_mock_now();
37
-
38
-        parent::tearDown();
39
-    }
40
-
41
-    abstract protected function getStore();
42
-
43
-    /**
44
-     * Test how this store handles large volumes of data (>1000 characters)
45
-     */
46
-    public function testStoreLargeData()
47
-    {
48
-        $session = uniqid();
49
-        $store = $this->getStore();
50
-
51
-        // Test new session is blank
52
-        $result = $store->read($session);
53
-        $this->assertEmpty($result);
54
-
55
-        // Save data against session
56
-        $data1 = array(
57
-            'Large' => str_repeat('A', 600),
58
-            'Content' => str_repeat('B', 600)
59
-        );
60
-        $store->write($session, serialize($data1));
61
-        $result = $store->read($session);
62
-        $this->assertEquals($data1, unserialize($result));
63
-    }
64
-
65
-    /**
66
-     * Test storage of data
67
-     */
68
-    public function testStoreData()
69
-    {
70
-        $session = uniqid();
71
-        $store = $this->getStore();
72
-
73
-        // Test new session is blank
74
-        $result = $store->read($session);
75
-        $this->assertEmpty($result);
76
-
77
-        // Save data against session
78
-        $data1 = array(
79
-            'Color' => 'red',
80
-            'Animal' => 'elephant'
81
-        );
82
-        $store->write($session, serialize($data1));
83
-        $result = $store->read($session);
84
-        $this->assertEquals($data1, unserialize($result));
85
-
86
-        // Save larger data
87
-        $data2 = array(
88
-            'Color' => 'blue',
89
-            'Animal' => str_repeat('bat', 100)
90
-        );
91
-        $store->write($session, serialize($data2));
92
-        $result = $store->read($session);
93
-        $this->assertEquals($data2, unserialize($result));
94
-    }
95
-
96
-    /**
97
-     * Test expiry of data
98
-     */
99
-    public function testExpiry()
100
-    {
101
-        $session1 = uniqid();
102
-        $store = $this->getStore();
103
-
104
-        // Store data now
105
-        $data1 = array(
106
-            'Food' => 'Pizza'
107
-        );
108
-        $store->write($session1, serialize($data1));
109
-        $result1 = $store->read($session1);
110
-        $this->assertEquals($data1, unserialize($result1));
111
-
112
-        // Go to the future and test that the expiry is accurate
113
-        DBDatetime::set_mock_now('2040-03-16 12:00:00');
114
-        $result2 = $store->read($session1);
115
-
116
-        $this->assertEmpty($result2);
117
-    }
13
+	public function setUp()
14
+	{
15
+		parent::setUp();
16
+
17
+		TestCookieStore::$override_headers_sent = false;
18
+
19
+		Injector::nest();
20
+		Injector::inst()->registerService(
21
+			new TestCookieStore(),
22
+			CookieStore::class
23
+		);
24
+
25
+		DBDatetime::set_mock_now('2010-03-15 12:00:00');
26
+
27
+		if (get_class() === get_class($this)) {
28
+			$this->markTestSkipped("Skipping abstract test");
29
+			$this->skipTest = true;
30
+		}
31
+	}
32
+
33
+	public function tearDown()
34
+	{
35
+		Injector::unnest();
36
+		DBDatetime::clear_mock_now();
37
+
38
+		parent::tearDown();
39
+	}
40
+
41
+	abstract protected function getStore();
42
+
43
+	/**
44
+	 * Test how this store handles large volumes of data (>1000 characters)
45
+	 */
46
+	public function testStoreLargeData()
47
+	{
48
+		$session = uniqid();
49
+		$store = $this->getStore();
50
+
51
+		// Test new session is blank
52
+		$result = $store->read($session);
53
+		$this->assertEmpty($result);
54
+
55
+		// Save data against session
56
+		$data1 = array(
57
+			'Large' => str_repeat('A', 600),
58
+			'Content' => str_repeat('B', 600)
59
+		);
60
+		$store->write($session, serialize($data1));
61
+		$result = $store->read($session);
62
+		$this->assertEquals($data1, unserialize($result));
63
+	}
64
+
65
+	/**
66
+	 * Test storage of data
67
+	 */
68
+	public function testStoreData()
69
+	{
70
+		$session = uniqid();
71
+		$store = $this->getStore();
72
+
73
+		// Test new session is blank
74
+		$result = $store->read($session);
75
+		$this->assertEmpty($result);
76
+
77
+		// Save data against session
78
+		$data1 = array(
79
+			'Color' => 'red',
80
+			'Animal' => 'elephant'
81
+		);
82
+		$store->write($session, serialize($data1));
83
+		$result = $store->read($session);
84
+		$this->assertEquals($data1, unserialize($result));
85
+
86
+		// Save larger data
87
+		$data2 = array(
88
+			'Color' => 'blue',
89
+			'Animal' => str_repeat('bat', 100)
90
+		);
91
+		$store->write($session, serialize($data2));
92
+		$result = $store->read($session);
93
+		$this->assertEquals($data2, unserialize($result));
94
+	}
95
+
96
+	/**
97
+	 * Test expiry of data
98
+	 */
99
+	public function testExpiry()
100
+	{
101
+		$session1 = uniqid();
102
+		$store = $this->getStore();
103
+
104
+		// Store data now
105
+		$data1 = array(
106
+			'Food' => 'Pizza'
107
+		);
108
+		$store->write($session1, serialize($data1));
109
+		$result1 = $store->read($session1);
110
+		$this->assertEquals($data1, unserialize($result1));
111
+
112
+		// Go to the future and test that the expiry is accurate
113
+		DBDatetime::set_mock_now('2040-03-16 12:00:00');
114
+		$result2 = $store->read($session1);
115
+
116
+		$this->assertEmpty($result2);
117
+	}
118 118
 }
Please login to merge, or discard this patch.
tests/HybridSessionTest.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 class HybridSessionTest extends AbstractTest
11 11
 {
12 12
 
13
-    /**
14
-     * @return HybridSessionStore_Cookie
15
-     */
16
-    protected function getStore()
17
-    {
18
-        $store = Injector::inst()->create(HybridSession::class);
19
-        $store->setKey(uniqid());
20
-        $store->open(TempFolder::getTempFolder(BASE_PATH).'/'.__CLASS__, 'SESSIONCOOKIE');
13
+	/**
14
+	 * @return HybridSessionStore_Cookie
15
+	 */
16
+	protected function getStore()
17
+	{
18
+		$store = Injector::inst()->create(HybridSession::class);
19
+		$store->setKey(uniqid());
20
+		$store->open(TempFolder::getTempFolder(BASE_PATH).'/'.__CLASS__, 'SESSIONCOOKIE');
21 21
 
22
-        return $store;
23
-    }
22
+		return $store;
23
+	}
24 24
 }
Please login to merge, or discard this patch.