Passed
Push — 1.0.0-dev ( 407604...83bedf )
by nguereza
03:26
created
tests/tnhfw/libraries/PDFTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class PDFTest extends TestCase
6
-	{	
5
+    class PDFTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/libraries/AssetsTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class AssetsTest extends TestCase
6
-	{	
5
+    class AssetsTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/libraries/FormValidationTest.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 use PHPUnit\Framework\TestCase;
3 3
 class FormValidationTest extends TestCase
4 4
 {   
5
-	public static function setUpBeforeClass()
5
+    public static function setUpBeforeClass()
6 6
     {
7 7
     
8 8
     }
9 9
 	
10
-	public static function tearDownAfterClass()
10
+    public static function tearDownAfterClass()
11 11
     {
12 12
         
13 13
     }
@@ -27,109 +27,109 @@  discard block
 block discarded – undo
27 27
     // tests
28 28
     public function testValidationDataIsEmpty()
29 29
     {
30
-		$fv = new FormValidation();
31
-		$this->assertEmpty($fv->getData());
30
+        $fv = new FormValidation();
31
+        $this->assertEmpty($fv->getData());
32 32
     }
33 33
 	
34
-	public function testValidationDataIsNotEmpty()
34
+    public function testValidationDataIsNotEmpty()
35 35
     {
36
-		$fv = new FormValidation();
37
-		$fv->setData(array('name' => 'mike'));
38
-		$this->assertNotEmpty($fv->getData());
39
-		$this->assertArrayHasKey('name', $fv->getData());
36
+        $fv = new FormValidation();
37
+        $fv->setData(array('name' => 'mike'));
38
+        $this->assertNotEmpty($fv->getData());
39
+        $this->assertArrayHasKey('name', $fv->getData());
40 40
     }
41 41
 	
42
-	public function testCannotDoValidation()
42
+    public function testCannotDoValidation()
43 43
     {
44
-		$fv = new FormValidation();
45
-		$this->assertFalse($fv->canDoValidation());
44
+        $fv = new FormValidation();
45
+        $this->assertFalse($fv->canDoValidation());
46 46
     }
47 47
 
48
-	public function testSettingErrorDelimiter()
48
+    public function testSettingErrorDelimiter()
49 49
     {
50
-		$fv = new FormValidation();
51
-		$fv->setErrorDelimiter('<a>', '</b>');
52
-		$this->assertContains('<a>', $fv->getErrorDelimiter());
53
-		$this->assertContains('</b>', $fv->getErrorDelimiter());
50
+        $fv = new FormValidation();
51
+        $fv->setErrorDelimiter('<a>', '</b>');
52
+        $this->assertContains('<a>', $fv->getErrorDelimiter());
53
+        $this->assertContains('</b>', $fv->getErrorDelimiter());
54 54
     }
55 55
 	
56
-	public function testSettingErrorsDelimiter()
56
+    public function testSettingErrorsDelimiter()
57 57
     {
58
-		$fv = new FormValidation();
59
-		$fv->setErrorsDelimiter('<foo>', '</bar>');
60
-		$this->assertContains('<foo>', $fv->getErrorsDelimiter());
61
-		$this->assertContains('</bar>', $fv->getErrorsDelimiter());
58
+        $fv = new FormValidation();
59
+        $fv->setErrorsDelimiter('<foo>', '</bar>');
60
+        $this->assertContains('<foo>', $fv->getErrorsDelimiter());
61
+        $this->assertContains('</bar>', $fv->getErrorsDelimiter());
62 62
     }
63 63
 	
64
-	public function testSettingErrorMessageOverride()
64
+    public function testSettingErrorMessageOverride()
65 65
     {
66 66
 		
67
-		//field specific message for the rule
68
-		$fv = new FormValidation();
69
-		$fv->setData(array('foo' => ''));
70
-		$fv->setRule('foo', 'bar', 'required');
71
-		$fv->setMessage('required', 'foo', 'foo required message error');
67
+        //field specific message for the rule
68
+        $fv = new FormValidation();
69
+        $fv->setData(array('foo' => ''));
70
+        $fv->setRule('foo', 'bar', 'required');
71
+        $fv->setMessage('required', 'foo', 'foo required message error');
72 72
 		
73
-		$this->assertFalse($fv->run());
74
-		$this->assertContains('foo required message error', $fv->returnErrors());
73
+        $this->assertFalse($fv->run());
74
+        $this->assertContains('foo required message error', $fv->returnErrors());
75 75
 		
76
-		//global message for the rule
77
-		$fv = new FormValidation();
78
-		$fv->setData(array('foo' => '', 'bar' => null));
79
-		$fv->setRule('foo', 'bar', 'required');
80
-		$fv->setRule('bar', 'foo', 'required');
81
-		$fv->setMessage('required', 'global required message error');
76
+        //global message for the rule
77
+        $fv = new FormValidation();
78
+        $fv->setData(array('foo' => '', 'bar' => null));
79
+        $fv->setRule('foo', 'bar', 'required');
80
+        $fv->setRule('bar', 'foo', 'required');
81
+        $fv->setMessage('required', 'global required message error');
82 82
 
83
-		$this->assertFalse($fv->run());
84
-		$this->assertContains('global required message error', $fv->returnErrors());
83
+        $this->assertFalse($fv->run());
84
+        $this->assertContains('global required message error', $fv->returnErrors());
85 85
     }
86 86
 	
87
-	public function testSettingCustomErrorMessage()
87
+    public function testSettingCustomErrorMessage()
88 88
     {
89 89
 		
90
-		$fv = new FormValidation();
91
-		$fv->setData(array('foo' => ''));
92
-		$fv->setRule('foo', 'bar', 'required');
93
-		$fv->setCustomError('foo', 'custom foo message error');
90
+        $fv = new FormValidation();
91
+        $fv->setData(array('foo' => ''));
92
+        $fv->setRule('foo', 'bar', 'required');
93
+        $fv->setCustomError('foo', 'custom foo message error');
94 94
 		
95
-		$this->assertFalse($fv->run());
96
-		$this->assertContains('custom foo message error', $fv->returnErrors());
95
+        $this->assertFalse($fv->run());
96
+        $this->assertContains('custom foo message error', $fv->returnErrors());
97 97
 		
98
-		//with label in the message
99
-		$fv = new FormValidation();
100
-		$fv->setData(array('foo' => ''));
101
-		$fv->setRule('foo', 'bar', 'required');
102
-		$fv->setCustomError('foo', 'custom "%1" message error');
98
+        //with label in the message
99
+        $fv = new FormValidation();
100
+        $fv->setData(array('foo' => ''));
101
+        $fv->setRule('foo', 'bar', 'required');
102
+        $fv->setCustomError('foo', 'custom "%1" message error');
103 103
 		
104
-		$this->assertFalse($fv->run());
105
-		$this->assertContains('custom "bar" message error', $fv->returnErrors());	
104
+        $this->assertFalse($fv->run());
105
+        $this->assertContains('custom "bar" message error', $fv->returnErrors());	
106 106
     }
107 107
 	
108
-	public function testReturnErrorsArray()
108
+    public function testReturnErrorsArray()
109 109
     {
110
-		$fv = new FormValidation();
111
-		$fv->setRule('name', 'name', 'required');
112
-		$fv->setData(array('name' => ''));
113
-		$this->assertFalse($fv->run());
114
-		$this->assertNotEmpty($fv->returnErrors());
110
+        $fv = new FormValidation();
111
+        $fv->setRule('name', 'name', 'required');
112
+        $fv->setData(array('name' => ''));
113
+        $this->assertFalse($fv->run());
114
+        $this->assertNotEmpty($fv->returnErrors());
115 115
     }
116 116
 	
117 117
 	
118
-	public function testRequiredRule()
118
+    public function testRequiredRule()
119 119
     {
120
-		$fv = new FormValidation();
121
-		$fv->setRule('name', 'name', 'required');
122
-		$fv->setData(array('name' => ''));
123
-		$this->assertFalse($fv->run());
120
+        $fv = new FormValidation();
121
+        $fv->setRule('name', 'name', 'required');
122
+        $fv->setData(array('name' => ''));
123
+        $this->assertFalse($fv->run());
124 124
 		
125
-		$fv = new FormValidation();
126
-		$fv->setRule('name', 'name', 'required');
127
-		$fv->setData(array('name' => null));
128
-		$this->assertFalse($fv->run());
125
+        $fv = new FormValidation();
126
+        $fv->setRule('name', 'name', 'required');
127
+        $fv->setData(array('name' => null));
128
+        $this->assertFalse($fv->run());
129 129
 		
130
-		$fv = new FormValidation();
131
-		$fv->setRule('name', 'name', 'required');
132
-		$fv->setData(array('name' => 'tony'));
133
-		$this->assertTrue($fv->run());
130
+        $fv = new FormValidation();
131
+        $fv->setRule('name', 'name', 'required');
132
+        $fv->setData(array('name' => 'tony'));
133
+        $this->assertTrue($fv->run());
134 134
     }
135 135
 }
136 136
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/libraries/PaginationTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class PaginationTest extends TestCase
6
-	{	
5
+    class PaginationTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/CommonTest.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,50 +1,50 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class CommonTest extends TestCase
6
-	{	
5
+    class CommonTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 			
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 	
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 
26 26
 		
27
-		public function testFunctionGetConfigKeyNotExist(){
28
-			$key = 'foo';
29
-			$cfg = get_config($key);
30
-			$this->assertNull($cfg);
31
-		}
27
+        public function testFunctionGetConfigKeyNotExist(){
28
+            $key = 'foo';
29
+            $cfg = get_config($key);
30
+            $this->assertNull($cfg);
31
+        }
32 32
 		
33
-		public function testFunctionGetConfigKeyNotExistUsingDefaultValue(){
34
-			$key = 'foo';
35
-			$expected = 'bar';
36
-			$cfg = get_config($key, $expected);
37
-			$this->assertEquals($cfg, $expected);
38
-		}
33
+        public function testFunctionGetConfigKeyNotExistUsingDefaultValue(){
34
+            $key = 'foo';
35
+            $expected = 'bar';
36
+            $cfg = get_config($key, $expected);
37
+            $this->assertEquals($cfg, $expected);
38
+        }
39 39
 		
40
-		public function testFunctionGetConfigAfterSet(){
41
-			$key = 'foo';
42
-			$expected = 'bar';
43
-			$c = new Config();
44
-			$c->init();
45
-			$c->set($key, $expected);
46
-			$cfg = get_config($key);
47
-			$this->assertEquals($cfg, $expected);
48
-		}
40
+        public function testFunctionGetConfigAfterSet(){
41
+            $key = 'foo';
42
+            $expected = 'bar';
43
+            $c = new Config();
44
+            $c->init();
45
+            $c->set($key, $expected);
46
+            $cfg = get_config($key);
47
+            $this->assertEquals($cfg, $expected);
48
+        }
49 49
 		
50
-	}
51 50
\ No newline at end of file
51
+    }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
tests/include/testsUtil.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	/**
4
-	* Function to test private & protected method
5
-	*/
6
-	function runPrivateOrProtectedMethod($object, $method, array $args = array()){
7
-		$r = new ReflectionClass(get_class($object));
8
-		$m = $r->getMethod($method);
9
-		$m->setAccessible(true);
10
-		return $m->invokeArgs($object, $args);
11
-	}
12 3
\ No newline at end of file
4
+    /**
5
+     * Function to test private & protected method
6
+     */
7
+    function runPrivateOrProtectedMethod($object, $method, array $args = array()){
8
+        $r = new ReflectionClass(get_class($object));
9
+        $m = $r->getMethod($method);
10
+        $m->setAccessible(true);
11
+        return $m->invokeArgs($object, $args);
12
+    }
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
tests/include/common.php 1 patch
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -1,240 +1,240 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27 27
 
28
-	function & class_loader($class, $dir = 'libraries', $params = null){
29
-		//put the first letter of class to upper case 
30
-		$class = ucfirst($class);
31
-		static $classes = array();
32
-		if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
33
-			return $classes[$class];
34
-		}
35
-		$found = false;
36
-		foreach (array(ROOT_PATH, CORE_PATH) as $path) {
37
-			$file = $path . $dir . '/' . $class . '.php';
38
-			if(file_exists($file)){
39
-				if(class_exists($class, false) === false){
40
-					require_once $file;
41
-				}
42
-				//already found
43
-				$found = true;
44
-				break;
45
-			}
46
-		}
47
-		if(! $found){
48
-			//can't use show_error() at this time because some dependencies not yet loaded
49
-			set_http_status_header(503);
50
-			echo 'Cannot find the class [' . $class . ']';
51
-			die();
52
-		}
28
+    function & class_loader($class, $dir = 'libraries', $params = null){
29
+        //put the first letter of class to upper case 
30
+        $class = ucfirst($class);
31
+        static $classes = array();
32
+        if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
33
+            return $classes[$class];
34
+        }
35
+        $found = false;
36
+        foreach (array(ROOT_PATH, CORE_PATH) as $path) {
37
+            $file = $path . $dir . '/' . $class . '.php';
38
+            if(file_exists($file)){
39
+                if(class_exists($class, false) === false){
40
+                    require_once $file;
41
+                }
42
+                //already found
43
+                $found = true;
44
+                break;
45
+            }
46
+        }
47
+        if(! $found){
48
+            //can't use show_error() at this time because some dependencies not yet loaded
49
+            set_http_status_header(503);
50
+            echo 'Cannot find the class [' . $class . ']';
51
+            die();
52
+        }
53 53
 		
54
-		/*
54
+        /*
55 55
 		   TODO use the best method to get the Log instance
56 56
 		 */
57
-		if($class == 'Log'){
58
-			//can't use the instruction like "return new Log()" 
59
-			//because we need return the reference instance of the loaded class.
60
-			$log = new Log();
61
-			return $log;
62
-		}
63
-		//track of loaded classes
64
-		class_loaded($class);
57
+        if($class == 'Log'){
58
+            //can't use the instruction like "return new Log()" 
59
+            //because we need return the reference instance of the loaded class.
60
+            $log = new Log();
61
+            return $log;
62
+        }
63
+        //track of loaded classes
64
+        class_loaded($class);
65 65
 		
66
-		//record the class instance
67
-		$classes[$class] = isset($params) ? new $class($params) : new $class();
66
+        //record the class instance
67
+        $classes[$class] = isset($params) ? new $class($params) : new $class();
68 68
 		
69
-		return $classes[$class];
70
-	}
69
+        return $classes[$class];
70
+    }
71 71
 
72 72
 
73
-	function & class_loaded($class = null){
74
-		static $list = array();
75
-		if($class != null){
76
-			$list[strtolower($class)] = $class;
77
-		}
78
-		return $list;
79
-	}
73
+    function & class_loaded($class = null){
74
+        static $list = array();
75
+        if($class != null){
76
+            $list[strtolower($class)] = $class;
77
+        }
78
+        return $list;
79
+    }
80 80
 
81
-	function & load_configurations(array $overwrite_values = array()){
82
-		static $config;
83
-		if(empty($config)){
84
-			$file = CONFIG_PATH . 'config.php';
85
-			require_once $file;
81
+    function & load_configurations(array $overwrite_values = array()){
82
+        static $config;
83
+        if(empty($config)){
84
+            $file = CONFIG_PATH . 'config.php';
85
+            require_once $file;
86 86
 		
87
-			foreach ($overwrite_values as $key => $value) {
88
-				$config[$key] = $value;
89
-			}
90
-		}
91
-		return $config;
92
-	}
87
+            foreach ($overwrite_values as $key => $value) {
88
+                $config[$key] = $value;
89
+            }
90
+        }
91
+        return $config;
92
+    }
93 93
 
94
-	/**
95
-	*  @test
96
-	*/
97
-	function get_config($key, $default = null){
98
-		static $cfg;
99
-		if(empty($cfg)){
100
-			$cfg[0] = & load_configurations();
101
-		}
102
-		return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
103
-	}
94
+    /**
95
+     *  @test
96
+     */
97
+    function get_config($key, $default = null){
98
+        static $cfg;
99
+        if(empty($cfg)){
100
+            $cfg[0] = & load_configurations();
101
+        }
102
+        return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
103
+    }
104 104
 
105
-	function save_to_log($level, $message, $logger = null){
106
-		echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n";
107
-	}
105
+    function save_to_log($level, $message, $logger = null){
106
+        echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n";
107
+    }
108 108
 
109 109
 	
110
-	function set_http_status_header($code = 200, $text = null){
111
-		echo 'header(' . $code . ', ' . $text . ')';
112
-		return true;
113
-	}
110
+    function set_http_status_header($code = 200, $text = null){
111
+        echo 'header(' . $code . ', ' . $text . ')';
112
+        return true;
113
+    }
114 114
 
115 115
 	
116
-	function show_error($msg, $title = 'error', $logging = true){
117
-		//show only and continue to help track of some error occured
118
-		echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n";
119
-	}
116
+    function show_error($msg, $title = 'error', $logging = true){
117
+        //show only and continue to help track of some error occured
118
+        echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n";
119
+    }
120 120
 
121
-	function is_https(){
122
-		return false;
123
-	}
121
+    function is_https(){
122
+        return false;
123
+    }
124 124
 	
125
-	/**
126
-	*  @test
127
-	*/
128
-	function is_url($url){
129
-		return preg_match('/^(http|https|ftp):\/\/(.*)/', $url);
130
-	}
125
+    /**
126
+     *  @test
127
+     */
128
+    function is_url($url){
129
+        return preg_match('/^(http|https|ftp):\/\/(.*)/', $url);
130
+    }
131 131
 		
132
-	function php_exception_handler($ex){
133
-		//show only and continue to help track of some error occured
134
-		echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n";
135
-	}
132
+    function php_exception_handler($ex){
133
+        //show only and continue to help track of some error occured
134
+        echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n";
135
+    }
136 136
 	
137 137
 	
138
-	function php_error_handler($errno , $errstr, $errfile , $errline){
139
-		//show only and continue to help track of some error occured
140
-		echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n";
141
-	}
138
+    function php_error_handler($errno , $errstr, $errfile , $errline){
139
+        //show only and continue to help track of some error occured
140
+        echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n";
141
+    }
142 142
 
143
-	function php_shudown_handler(){
144
-		return true;
145
-	}
143
+    function php_shudown_handler(){
144
+        return true;
145
+    }
146 146
 
147 147
 
148
-	/**
149
-	*  @test
150
-	*/
151
-	function attributes_to_string(array $attributes){
152
-		$str = ' ';
153
-		//we check that the array passed as an argument is not empty.
154
-		if(! empty($attributes)){
155
-			foreach($attributes as $key => $value){
156
-				$key = trim(htmlspecialchars($key));
157
-				$value = trim(htmlspecialchars($value));
158
-				/*
148
+    /**
149
+     *  @test
150
+     */
151
+    function attributes_to_string(array $attributes){
152
+        $str = ' ';
153
+        //we check that the array passed as an argument is not empty.
154
+        if(! empty($attributes)){
155
+            foreach($attributes as $key => $value){
156
+                $key = trim(htmlspecialchars($key));
157
+                $value = trim(htmlspecialchars($value));
158
+                /*
159 159
 				* To predict the case where the string to convert contains the character "
160 160
 				* we check if this is the case we add a slash to solve this problem.
161 161
 				* For example:
162 162
 				* 	$attr = array('placeholder' => 'I am a "puple"')
163 163
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
164 164
 				 */
165
-				if($value && strpos('"', $value) !== false){
166
-					$value = addslashes($value);
167
-				}
168
-				$str .= $key.' = "'.$value.'" ';
169
-			}
170
-		}
171
-		//remove the space after using rtrim()
172
-		return rtrim($str);
173
-	}
165
+                if($value && strpos('"', $value) !== false){
166
+                    $value = addslashes($value);
167
+                }
168
+                $str .= $key.' = "'.$value.'" ';
169
+            }
170
+        }
171
+        //remove the space after using rtrim()
172
+        return rtrim($str);
173
+    }
174 174
 
175
-	function stringfy_vars($var){
176
-		return print_r($var, true);
177
-	}
175
+    function stringfy_vars($var){
176
+        return print_r($var, true);
177
+    }
178 178
 
179
-	/**
180
-	*  @test
181
-	*/
182
-	function clean_input($str){
183
-		if(is_array($str)){
184
-			$str = array_map('clean_input', $str);
185
-		}
186
-		else if(is_object($str)){
187
-			$obj = $str;
188
-			foreach ($str as $var => $value) {
189
-				$obj->$var = clean_input($value);
190
-			}
191
-			$str = $obj;
192
-		}
193
-		else{
194
-			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
195
-		}
196
-		return $str;
197
-	}
179
+    /**
180
+     *  @test
181
+     */
182
+    function clean_input($str){
183
+        if(is_array($str)){
184
+            $str = array_map('clean_input', $str);
185
+        }
186
+        else if(is_object($str)){
187
+            $obj = $str;
188
+            foreach ($str as $var => $value) {
189
+                $obj->$var = clean_input($value);
190
+            }
191
+            $str = $obj;
192
+        }
193
+        else{
194
+            $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
195
+        }
196
+        return $str;
197
+    }
198 198
 	
199
-	/**
200
-	*  @test
201
-	*/
202
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
203
-		//get the string length
204
-		$len = strlen($str);
205
-		//if str is empty
206
-		if($len <= 0){
207
-			return str_repeat($hiddenChar, 6);
208
-		}
209
-		//if the length is less than startCount and endCount
210
-		//or the startCount and endCount length is 0
211
-		//or startCount is negative or endCount is negative
212
-		//return the full string hidden
199
+    /**
200
+     *  @test
201
+     */
202
+    function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
203
+        //get the string length
204
+        $len = strlen($str);
205
+        //if str is empty
206
+        if($len <= 0){
207
+            return str_repeat($hiddenChar, 6);
208
+        }
209
+        //if the length is less than startCount and endCount
210
+        //or the startCount and endCount length is 0
211
+        //or startCount is negative or endCount is negative
212
+        //return the full string hidden
213 213
 		
214
-		if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
215
-			return str_repeat($hiddenChar, $len);
216
-		}
217
-		//the start non hidden string
218
-		$startNonHiddenStr = substr($str, 0, $startCount);
219
-		//the end non hidden string
220
-		$endNonHiddenStr = null;
221
-		if($endCount > 0){
222
-			$endNonHiddenStr = substr($str, - $endCount);
223
-		}
224
-		//the hidden string
225
-		$hiddenStr = str_repeat($hiddenChar, $len - ($startCount + $endCount));
214
+        if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
215
+            return str_repeat($hiddenChar, $len);
216
+        }
217
+        //the start non hidden string
218
+        $startNonHiddenStr = substr($str, 0, $startCount);
219
+        //the end non hidden string
220
+        $endNonHiddenStr = null;
221
+        if($endCount > 0){
222
+            $endNonHiddenStr = substr($str, - $endCount);
223
+        }
224
+        //the hidden string
225
+        $hiddenStr = str_repeat($hiddenChar, $len - ($startCount + $endCount));
226 226
 		
227
-		return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr;
228
-	}
227
+        return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr;
228
+    }
229 229
 	
230
-	function set_session_config(){
231
-		return true;
232
-	}
230
+    function set_session_config(){
231
+        return true;
232
+    }
233 233
 	
234
-	function & get_instance(){
235
-		if(! Controller::get_instance()){
236
-			$c = new Controller();
237
-			return $c;
238
-		}
239
-		return Controller::get_instance();
240
-	}
234
+    function & get_instance(){
235
+        if(! Controller::get_instance()){
236
+            $c = new Controller();
237
+            return $c;
238
+        }
239
+        return Controller::get_instance();
240
+    }
Please login to merge, or discard this patch.
tests/include/autoloader.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,54 +1,54 @@
 block discarded – undo
1 1
 <?php
2
-	//Autoload function
3
-	function tests_autoload($class){
4
-		$classesMap = array(
5
-			//Caches
6
-			'ApcCache' => CORE_CLASSES_CACHE_PATH . 'ApcCache.php',
7
-			'CacheInterface' => CORE_CLASSES_CACHE_PATH . 'CacheInterface.php',
8
-			'FileCache' => CORE_CLASSES_CACHE_PATH . 'FileCache.php',
9
-			//models
10
-			'DBSessionHandlerModel' => CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php',
11
-			'Model' => CORE_CLASSES_MODEL_PATH . 'Model.php',
12
-			//Core classes
13
-			'Config' => CORE_CLASSES_PATH . 'Config.php',
14
-			'Controller' => CORE_CLASSES_PATH . 'Controller.php',
15
-			'Database' => CORE_CLASSES_DATABASE_PATH . 'Database.php',
16
-			'DatabaseQueryBuilder' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryBuilder.php',
17
-			'DatabaseQueryResult' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryResult.php',
18
-			'DatabaseQueryRunner' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryRunner.php',
19
-			'DBSessionHandler' => CORE_CLASSES_PATH . 'DBSessionHandler.php',
20
-			'EventInfo' => CORE_CLASSES_PATH . 'EventInfo.php',
21
-			'EventDispatcher' => CORE_CLASSES_PATH . 'EventDispatcher.php',
22
-			'Lang' => CORE_CLASSES_PATH . 'Lang.php',
23
-			'Loader' => CORE_CLASSES_PATH . 'Loader.php',
24
-			'Log' => CORE_CLASSES_PATH . 'Log.php',
25
-			'Module' => CORE_CLASSES_PATH . 'Module.php',
26
-			'Request' => CORE_CLASSES_PATH . 'Request.php',
27
-			'Response' => CORE_CLASSES_PATH . 'Response.php',
28
-			'Router' => CORE_CLASSES_PATH . 'Router.php',
29
-			'Security' => CORE_CLASSES_PATH . 'Security.php',
30
-			'Session' => CORE_CLASSES_PATH . 'Session.php',
31
-			'Url' => CORE_CLASSES_PATH . 'Url.php',
32
-			//Core libraries
33
-			'Assets' => CORE_LIBRARY_PATH . 'Assets.php',
34
-			'Benchmark' => CORE_LIBRARY_PATH . 'Benchmark.php',
35
-			'Browser' => CORE_LIBRARY_PATH . 'Browser.php',
36
-			'Cookie' => CORE_LIBRARY_PATH . 'Cookie.php',
37
-			'Email' => CORE_LIBRARY_PATH . 'Email.php',
38
-			'Form' => CORE_LIBRARY_PATH . 'Form.php',
39
-			'FormValidation' => CORE_LIBRARY_PATH . 'FormValidation.php',
40
-			'Html' => CORE_LIBRARY_PATH . 'Html.php',
41
-			'Pagination' => CORE_LIBRARY_PATH . 'Pagination.php',
42
-			'PDF' => CORE_LIBRARY_PATH . 'PDF.php',
43
-			'StringHash' => CORE_LIBRARY_PATH . 'StringHash.php',
44
-			'Upload' => CORE_LIBRARY_PATH . 'Upload.php',
45
-		);
46
-		if(isset($classesMap[$class])){
47
-			if(file_exists($classesMap[$class])){
48
-				require_once $classesMap[$class];
49
-			}
50
-			else{
51
-				echo 'File for class ' . $class . ' not found';
52
-			}
53
-		}
54
-	}
55 2
\ No newline at end of file
3
+    //Autoload function
4
+    function tests_autoload($class){
5
+        $classesMap = array(
6
+            //Caches
7
+            'ApcCache' => CORE_CLASSES_CACHE_PATH . 'ApcCache.php',
8
+            'CacheInterface' => CORE_CLASSES_CACHE_PATH . 'CacheInterface.php',
9
+            'FileCache' => CORE_CLASSES_CACHE_PATH . 'FileCache.php',
10
+            //models
11
+            'DBSessionHandlerModel' => CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php',
12
+            'Model' => CORE_CLASSES_MODEL_PATH . 'Model.php',
13
+            //Core classes
14
+            'Config' => CORE_CLASSES_PATH . 'Config.php',
15
+            'Controller' => CORE_CLASSES_PATH . 'Controller.php',
16
+            'Database' => CORE_CLASSES_DATABASE_PATH . 'Database.php',
17
+            'DatabaseQueryBuilder' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryBuilder.php',
18
+            'DatabaseQueryResult' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryResult.php',
19
+            'DatabaseQueryRunner' => CORE_CLASSES_DATABASE_PATH . 'DatabaseQueryRunner.php',
20
+            'DBSessionHandler' => CORE_CLASSES_PATH . 'DBSessionHandler.php',
21
+            'EventInfo' => CORE_CLASSES_PATH . 'EventInfo.php',
22
+            'EventDispatcher' => CORE_CLASSES_PATH . 'EventDispatcher.php',
23
+            'Lang' => CORE_CLASSES_PATH . 'Lang.php',
24
+            'Loader' => CORE_CLASSES_PATH . 'Loader.php',
25
+            'Log' => CORE_CLASSES_PATH . 'Log.php',
26
+            'Module' => CORE_CLASSES_PATH . 'Module.php',
27
+            'Request' => CORE_CLASSES_PATH . 'Request.php',
28
+            'Response' => CORE_CLASSES_PATH . 'Response.php',
29
+            'Router' => CORE_CLASSES_PATH . 'Router.php',
30
+            'Security' => CORE_CLASSES_PATH . 'Security.php',
31
+            'Session' => CORE_CLASSES_PATH . 'Session.php',
32
+            'Url' => CORE_CLASSES_PATH . 'Url.php',
33
+            //Core libraries
34
+            'Assets' => CORE_LIBRARY_PATH . 'Assets.php',
35
+            'Benchmark' => CORE_LIBRARY_PATH . 'Benchmark.php',
36
+            'Browser' => CORE_LIBRARY_PATH . 'Browser.php',
37
+            'Cookie' => CORE_LIBRARY_PATH . 'Cookie.php',
38
+            'Email' => CORE_LIBRARY_PATH . 'Email.php',
39
+            'Form' => CORE_LIBRARY_PATH . 'Form.php',
40
+            'FormValidation' => CORE_LIBRARY_PATH . 'FormValidation.php',
41
+            'Html' => CORE_LIBRARY_PATH . 'Html.php',
42
+            'Pagination' => CORE_LIBRARY_PATH . 'Pagination.php',
43
+            'PDF' => CORE_LIBRARY_PATH . 'PDF.php',
44
+            'StringHash' => CORE_LIBRARY_PATH . 'StringHash.php',
45
+            'Upload' => CORE_LIBRARY_PATH . 'Upload.php',
46
+        );
47
+        if(isset($classesMap[$class])){
48
+            if(file_exists($classesMap[$class])){
49
+                require_once $classesMap[$class];
50
+            }
51
+            else{
52
+                echo 'File for class ' . $class . ' not found';
53
+            }
54
+        }
55
+    }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
config/autoload.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,94 +1,94 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework created using the concept of codeigniter with bootstrap twitter
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework created using the concept of codeigniter with bootstrap twitter
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	/**
28
-	* This file contains the configuration of resources that you want to load automatically: 
29
-	* personal or system libraries, configuration files, models, 
30
-	* personal functions or systems that are used most often in your application 
31
-	* instead of loading them every time you want to use it.
32
-	* Note: loading a lot of resources can decrease the performance of your application.
33
-	*/
27
+    /**
28
+     * This file contains the configuration of resources that you want to load automatically: 
29
+     * personal or system libraries, configuration files, models, 
30
+     * personal functions or systems that are used most often in your application 
31
+     * instead of loading them every time you want to use it.
32
+     * Note: loading a lot of resources can decrease the performance of your application.
33
+     */
34 34
 
35 35
 
36
-	/**
37
-	* If you have personal libraries or systems to load automatically, then list them in the following array.
38
-	* For example :
39
-	*
40
-	*	$autoload['libraries'] = array('library1', 'library1');
41
-	*
42
-	* Note: Personal libraries have priority over system libraries, 
43
-	* ie the loading order is as follows: it looks in the folder of the personal libraries, 
44
-	* if it is found, it is loaded, if not , we search in the system libraries folder, 
45
-	* before returning an error in case it does not find it.
46
-	*/
47
-	$autoload['libraries'] = array();
36
+    /**
37
+     * If you have personal libraries or systems to load automatically, then list them in the following array.
38
+     * For example :
39
+     *
40
+     *	$autoload['libraries'] = array('library1', 'library1');
41
+     *
42
+     * Note: Personal libraries have priority over system libraries, 
43
+     * ie the loading order is as follows: it looks in the folder of the personal libraries, 
44
+     * if it is found, it is loaded, if not , we search in the system libraries folder, 
45
+     * before returning an error in case it does not find it.
46
+     */
47
+    $autoload['libraries'] = array();
48 48
 
49
-	/**
50
-	* If you have configuration files to load automatically, then list them in the following array.
51
-	* For example :
52
-	*
53
-	*	$autoload['config'] = array('config1', 'config2');
54
-	*
55
-	* Note 1: the file name must have as prefix "config_" 
56
-	* for example "config_name_of_the_file_config.php" and contains as configuration variable the array $config,
57
-	* otherwise the system can not find this configuration file.
58
-	* For example :
59
-	*
60
-	*	$config['key1'] = value1;
61
-	* 	$config['key2'] = value2;
62
-	*
63
-	* Note 2: the files to be loaded must be in the folder defined by the constant "CONFIG_PATH" in "index.php".
64
-	*/
65
-	$autoload['config'] = array();
49
+    /**
50
+     * If you have configuration files to load automatically, then list them in the following array.
51
+     * For example :
52
+     *
53
+     *	$autoload['config'] = array('config1', 'config2');
54
+     *
55
+     * Note 1: the file name must have as prefix "config_" 
56
+     * for example "config_name_of_the_file_config.php" and contains as configuration variable the array $config,
57
+     * otherwise the system can not find this configuration file.
58
+     * For example :
59
+     *
60
+     *	$config['key1'] = value1;
61
+     * 	$config['key2'] = value2;
62
+     *
63
+     * Note 2: the files to be loaded must be in the folder defined by the constant "CONFIG_PATH" in "index.php".
64
+     */
65
+    $autoload['config'] = array();
66 66
 
67
-	/**
68
-	* If you have models to load automatically, then list them in the following table.
69
-	* For example :
70
-	*
71
-	*	$autoload['models'] = array('model1', 'model2');
72
-	*/
73
-	$autoload['models'] = array();
67
+    /**
68
+     * If you have models to load automatically, then list them in the following table.
69
+     * For example :
70
+     *
71
+     *	$autoload['models'] = array('model1', 'model2');
72
+     */
73
+    $autoload['models'] = array();
74 74
 
75
-	/**
76
-	* If you have system or personal functions to load automatically, specify them in the following array.
77
-	* For example :
78
-	*
79
-	* 	$autoload['functions'] = array('function1', 'function2');
80
-	*
81
-	* Note: Personal functions have priority over system functions,
82
-	* that is to say that the order of loading is the following : it looks in the directory of the personal functions,
83
-	* if it is found, it is loaded, otherwise, it looks in the directory of the system functions,
84
-	* before returning an error in case he does not find it.
85
-	*/
86
-	$autoload['functions'] = array();
75
+    /**
76
+     * If you have system or personal functions to load automatically, specify them in the following array.
77
+     * For example :
78
+     *
79
+     * 	$autoload['functions'] = array('function1', 'function2');
80
+     *
81
+     * Note: Personal functions have priority over system functions,
82
+     * that is to say that the order of loading is the following : it looks in the directory of the personal functions,
83
+     * if it is found, it is loaded, otherwise, it looks in the directory of the system functions,
84
+     * before returning an error in case he does not find it.
85
+     */
86
+    $autoload['functions'] = array();
87 87
 	
88
-	/**
89
-	* If you have system or personal language to load automatically, specify them in the following array.
90
-	* For example :
91
-	*
92
-	* 	$autoload['languages'] = array('lang1', 'lang2');
93
-	*/
94
-	$autoload['languages'] = array();
88
+    /**
89
+     * If you have system or personal language to load automatically, specify them in the following array.
90
+     * For example :
91
+     *
92
+     * 	$autoload['languages'] = array('lang1', 'lang2');
93
+     */
94
+    $autoload['languages'] = array();
Please login to merge, or discard this patch.