Completed
Push — master ( 394d07...75d991 )
by Ankit
02:48
created
views/validate_login.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require (dirname(__DIR__) . '/vendor/autoload.php');
3
+require (dirname(__DIR__).'/vendor/autoload.php');
4 4
 use ChatApp\Login;
5 5
 
6
-if(isset($_POST['q']))
6
+if (isset($_POST['q']))
7 7
 {
8 8
     $loginField = json_decode($_POST['q']);
9 9
     $login = $loginField->login;
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         'passLogin' => $password
15 15
     );
16 16
     $result = $obLogin->authLogin($data);
17
-    if(isset($result))
17
+    if (isset($result))
18 18
         echo $result;
19 19
     else
20 20
         echo json_encode([]);
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
         'passLogin' => $password
15 15
     );
16 16
     $result = $obLogin->authLogin($data);
17
-    if(isset($result))
18
-        echo $result;
19
-    else
20
-        echo json_encode([]);
21
-}
22 17
\ No newline at end of file
18
+    if(isset($result)) {
19
+            echo $result;
20
+    } else {
21
+            echo json_encode([]);
22
+    }
23
+    }
23 24
\ No newline at end of file
Please login to merge, or discard this patch.
views/validate_register.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -5,25 +5,25 @@
 block discarded – undo
5 5
 
6 6
 if(isset($_POST['q']))
7 7
 {
8
-	$registerField = json_decode($_POST['q']);
9
-	$name = $registerField->name;
10
-	$email = $registerField->email;
11
-	$username = $registerField->username;
12
-	$mob = $registerField->mob;
13
-	$password = $registerField->password;
14
-	$obRegister = new Register();
15
-	$data = array(
16
-		'name' => $name,
17
-		'email' => $email,
18
-		'username' => $username,
19
-		'passRegister' => $password,
20
-		'mob' => $mob
21
-	);
22
-	$result = $obRegister->authRegister($data);
23
-	if(isset($result))
24
-		echo $result;
25
-	else
26
-		echo json_encode([]);
8
+    $registerField = json_decode($_POST['q']);
9
+    $name = $registerField->name;
10
+    $email = $registerField->email;
11
+    $username = $registerField->username;
12
+    $mob = $registerField->mob;
13
+    $password = $registerField->password;
14
+    $obRegister = new Register();
15
+    $data = array(
16
+        'name' => $name,
17
+        'email' => $email,
18
+        'username' => $username,
19
+        'passRegister' => $password,
20
+        'mob' => $mob
21
+    );
22
+    $result = $obRegister->authRegister($data);
23
+    if(isset($result))
24
+        echo $result;
25
+    else
26
+        echo json_encode([]);
27 27
 }
28 28
 
29 29
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require (dirname(__DIR__) . '/vendor/autoload.php');
3
+require (dirname(__DIR__).'/vendor/autoload.php');
4 4
 use ChatApp\Register;
5 5
 
6
-if(isset($_POST['q']))
6
+if (isset($_POST['q']))
7 7
 {
8 8
 	$registerField = json_decode($_POST['q']);
9 9
 	$name = $registerField->name;
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 		'mob' => $mob
21 21
 	);
22 22
 	$result = $obRegister->authRegister($data);
23
-	if(isset($result))
23
+	if (isset($result))
24 24
 		echo $result;
25 25
 	else
26 26
 		echo json_encode([]);
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,11 +20,12 @@
 block discarded – undo
20 20
 		'mob' => $mob
21 21
 	);
22 22
 	$result = $obRegister->authRegister($data);
23
-	if(isset($result))
24
-		echo $result;
25
-	else
26
-		echo json_encode([]);
27
-}
23
+	if(isset($result)) {
24
+			echo $result;
25
+	} else {
26
+			echo json_encode([]);
27
+	}
28
+	}
28 29
 
29 30
 
30 31
 
Please login to merge, or discard this patch.
views/message.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -175,6 +175,6 @@
 block discarded – undo
175 175
 <?php
176 176
 }
177 177
 else{
178
-  header('Location:'. getenv('APP_URL')."/index.php");
178
+    header('Location:'. getenv('APP_URL')."/index.php");
179 179
 }
180 180
 ?>
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once (dirname(__DIR__) . '/vendor/autoload.php');
3
+require_once (dirname(__DIR__).'/vendor/autoload.php');
4 4
 use ChatApp\Session;
5 5
 use Dotenv\Dotenv;
6 6
 $dotenv = new Dotenv(dirname(__DIR__));
7 7
 $dotenv->load();
8 8
 
9
-if(Session::get('start') != null && empty($_GET['user']))
9
+if (Session::get('start') != null && empty($_GET['user']))
10 10
 {
11 11
 
12 12
 ?>
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 <?php
176 176
 }
177
-else{
178
-  header('Location:'. getenv('APP_URL')."/index.php");
177
+else {
178
+  header('Location:'.getenv('APP_URL')."/index.php");
179 179
 }
180 180
 ?>
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -168,8 +168,7 @@
 block discarded – undo
168 168
 </html>
169 169
 
170 170
 <?php
171
-}
172
-else{
171
+} else{
173 172
   header('Location:'. getenv('APP_URL')."/index.php");
174 173
 }
175 174
 ?>
Please login to merge, or discard this patch.
tests/TestUser.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     /**
54
-    * @depends test_authRegister
55
-    *  Testing for the register with empty username
56
-    */
54
+     * @depends test_authRegister
55
+     *  Testing for the register with empty username
56
+     */
57 57
     public function test_authregisterEmptyUsername()
58 58
     {
59 59
         $output = $this->obRegister->authregister(
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
     /**
80
-    * @depends test_authRegister
81
-    *  Testing for the register with invalid email credentials
82
-    */
80
+     * @depends test_authRegister
81
+     *  Testing for the register with invalid email credentials
82
+     */
83 83
     public function test_authregisterInvalidEmail()
84 84
     {
85 85
         $output = $this->obRegister->authregister(
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
     /**
106
-    * @depends test_authRegister
107
-    *  Testing for the register with repeated credentials
108
-    */
106
+     * @depends test_authRegister
107
+     *  Testing for the register with repeated credentials
108
+     */
109 109
     public function test_authregisterInvalidCredentials()
110 110
     {
111 111
         $output = $this->obRegister->authregister(
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
     }
138 138
 
139 139
     /**
140
-    * @depends test_authRegister
141
-    *  Testing for the login with correct credentials
142
-    */
140
+     * @depends test_authRegister
141
+     *  Testing for the login with correct credentials
142
+     */
143 143
 
144 144
     public function test_authLogin()
145 145
     {
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
     }
164 164
 
165 165
     /**
166
-    * @depends test_authRegister
167
-    *  Testing for the login with empty credentials
168
-    */
166
+     * @depends test_authRegister
167
+     *  Testing for the login with empty credentials
168
+     */
169 169
 
170 170
     public function test_authLoginEmptyValues()
171 171
     {
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
     /**
194
-    * @depends test_authRegister
195
-    *  Testing for the login with invalid or wrong email
196
-    */
194
+     * @depends test_authRegister
195
+     *  Testing for the login with invalid or wrong email
196
+     */
197 197
 
198 198
     public function test_authLoginWrongEmail()
199 199
     {
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
     }
216 216
 
217 217
     /**
218
-    * @depends test_authRegister
219
-    *  Testing for the login with invalid email credentials
220
-    */
218
+     * @depends test_authRegister
219
+     *  Testing for the login with invalid email credentials
220
+     */
221 221
     public function test_authLoginInvalidUsernameEmail()
222 222
     {
223 223
         $output = $this->obLogin->authLogin(
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
     }
239 239
 
240 240
     /**
241
-    * @depends test_authRegister
242
-    *  Testing for the login with invalid password credentials
243
-    */
241
+     * @depends test_authRegister
242
+     *  Testing for the login with invalid password credentials
243
+     */
244 244
     public function test_authLoginInvalidPassword()
245 245
     {
246 246
         $output = $this->obLogin->authLogin(
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
     }
261 261
 
262 262
     /**
263
-    * @depends test_authRegister
264
-    *  Testing for the Profile::class with valid login_id
265
-    */
263
+     * @depends test_authRegister
264
+     *  Testing for the Profile::class with valid login_id
265
+     */
266 266
     public function test_getProfile()
267 267
     {
268 268
         $output = Profile::getProfile(1);
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
     }
276 276
 
277 277
     /**
278
-    * @depends test_authRegister
279
-    *  Testing for the Profile::class with invalid login_id
280
-    */
278
+     * @depends test_authRegister
279
+     *  Testing for the Profile::class with invalid login_id
280
+     */
281 281
     public function test_getProfileInvalidID()
282 282
     {
283 283
         $output = Profile::getProfile(0);
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
     }
286 286
 
287 287
     /**
288
-    * @depends test_authRegister
289
-    *  Testing for the User::class with valid login_id
290
-    */
288
+     * @depends test_authRegister
289
+     *  Testing for the User::class with valid login_id
290
+     */
291 291
     public function test_userDetails()
292 292
     {
293 293
         $expectedOutput = [
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
     }
307 307
 
308 308
     /**
309
-    * @depends test_authRegister
310
-    *  Testing for the User::class with invalid data
311
-    */
309
+     * @depends test_authRegister
310
+     *  Testing for the User::class with invalid data
311
+     */
312 312
     public function test_userDetailsInvalidID()
313 313
     {
314 314
         $output = $this->obUser->userDetails(0, True);
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
     }
317 317
 
318 318
     /**
319
-    * @depends test_authRegister
320
-    *  Testing for the Validate::class for email
321
-    */
319
+     * @depends test_authRegister
320
+     *  Testing for the Validate::class for email
321
+     */
322 322
     public function test_validateEmailInDb()
323 323
     {
324 324
         $output = $this->obValidate->validateEmailInDb('[email protected]');
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
     }
327 327
 
328 328
     /**
329
-    * @depends test_authRegister
330
-    *  Testing for the Validate::class for username
331
-    */
329
+     * @depends test_authRegister
330
+     *  Testing for the Validate::class for username
331
+     */
332 332
     public function test_validateUsernameInDb()
333 333
     {
334 334
         $output = $this->obValidate->validateUsernameInDb('test');
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
     }
337 337
 
338 338
     /**
339
-    * @depends test_authRegister
340
-    *  Testing for the Validate::class for non-existing username
341
-    */
339
+     * @depends test_authRegister
340
+     *  Testing for the Validate::class for non-existing username
341
+     */
342 342
     public function test_validateUsernameInDbNot()
343 343
     {
344 344
         $output = $this->obValidate->validateUsernameInDb('abc');
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
     }
347 347
 
348 348
     /**
349
-    * @depends test_authRegister
350
-    *  Testing for the Validate::class for non-existing email
351
-    */
349
+     * @depends test_authRegister
350
+     *  Testing for the Validate::class for non-existing email
351
+     */
352 352
     public function test_validateEmailInDbNot()
353 353
     {
354 354
         $output = $this->obValidate->validateEmailInDb('[email protected]');
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
     }
357 357
 
358 358
     /**
359
-    * @depends test_authRegister
360
-    *  Testing for the Online::class
361
-    */
359
+     * @depends test_authRegister
360
+     *  Testing for the Online::class
361
+     */
362 362
     public function test_Online()
363 363
     {
364 364
         Online::setOnlineStatus(1);
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 
374 374
 
375 375
     /**
376
-    *   @depends test_Online
377
-    *  Empty the DB
378
-    */
376
+     *   @depends test_Online
377
+     *  Empty the DB
378
+     */
379 379
     public function test_EmptyDB()
380 380
     {
381 381
         $connect = mysqli_connect(
Please login to merge, or discard this patch.
tests/TestAll.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
     }
51 51
 
52 52
     /**
53
-    * @depends testAuthRegister
54
-    *  Register User2
55
-    */
53
+     * @depends testAuthRegister
54
+     *  Register User2
55
+     */
56 56
     public function testAuthRegister2()
57 57
     {
58 58
         $output = $this->obRegister->authRegister(
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
     /**
80
-    * @depends testAuthRegister2
81
-    *  Testing for the register with empty username
82
-    */
80
+     * @depends testAuthRegister2
81
+     *  Testing for the register with empty username
82
+     */
83 83
     public function testCompose()
84 84
     {
85 85
         $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php'];
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
     }
135 135
 
136 136
     /**
137
-    * @depends testAuthRegister2
138
-    *  Testing for Search Class
139
-    */
137
+     * @depends testAuthRegister2
138
+     *  Testing for Search Class
139
+     */
140 140
     public function testSearch($userId)
141 141
     {
142 142
         $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php'];
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 
179 179
 
180 180
     /**
181
-    * @depends testAuthRegister2
182
-    *  Testing for Reply Class
183
-    */
181
+     * @depends testAuthRegister2
182
+     *  Testing for Reply Class
183
+     */
184 184
     public function testReply($userId)
185 185
     {
186 186
         $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php'];
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 
237 237
 
238 238
     /**
239
-    * @depends testReply
240
-    *  Testing for Search Class
241
-    */
239
+     * @depends testReply
240
+     *  Testing for Search Class
241
+     */
242 242
     public function testSearchWithTotalMessages()
243 243
     {
244 244
         $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php'];
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
     }
265 265
 
266 266
     /**
267
-    *  Testing for Search Class
268
-    */
267
+     *  Testing for Search Class
268
+     */
269 269
     public function testSidebar()
270 270
     {
271 271
         $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php'];
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 
295 295
 
296 296
     /**
297
-    *   @depends testSidebar
298
-    *  Empty the DB
299
-    */
297
+     *   @depends testSidebar
298
+     *  Empty the DB
299
+     */
300 300
     public function test_EmptyDB()
301 301
     {
302 302
         $connect = mysqli_connect(
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 use ChatApp\Reply;
10 10
 use ChatApp\Session;
11 11
 use ChatApp\SideBar;
12
-
13 12
 use Dotenv\Dotenv;
14 13
 $dotenv = new Dotenv(dirname(__DIR__));
15 14
 $dotenv->load();
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
                 "passLogin" => 'testing'
191 191
             ]
192 192
         );
193
-        $outputEmail = (array) json_decode($outputEmail);
193
+        $outputEmail = (array)json_decode($outputEmail);
194 194
         $this->assertEquals($expectedOutput, $outputEmail);
195 195
         $currentId = Session::get('start');
196 196
         Session::forget('start');
197 197
 
198
-        $msg =(object) [
198
+        $msg = (object)[
199 199
             "name" => $userId,
200 200
             "reply" => "Hello World",
201 201
             "userId" => $currentId
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $output = $obReply->replyTo($msg);
206 206
         $this->assertEquals("Messages is sent", $output);
207 207
 
208
-        $msg =(object) [
208
+        $msg = (object)[
209 209
             "name" => $currentId,
210 210
             "reply" => "Hello World",
211 211
             "userId" => $userId
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
         $output = $obReply->replyTo([]);
219 219
         $this->assertEquals("Failed", $output);
220 220
 
221
-        $output = $obReply->replyTo((object) [
221
+        $output = $obReply->replyTo((object)[
222 222
             "name" => -1,
223 223
             "reply" => "Hello World",
224 224
             "userId" => $currentId
225 225
         ]);
226 226
         $this->assertEquals("Invalid Authentication", $output);
227 227
 
228
-        $output = $obReply->replyTo((object) [
228
+        $output = $obReply->replyTo((object)[
229 229
             "name" => $userId,
230 230
             "reply" => "Hello",
231 231
             "userId" => $currentId
Please login to merge, or discard this patch.
src/Session.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@
 block discarded – undo
10 10
         $_SESSION[$key] = $value;
11 11
     }
12 12
 
13
+    /**
14
+     * @param string $key
15
+     */
13 16
     public static function get($key){
14 17
         return (isset($_SESSION[$key]) ? $_SESSION[$key] : null);
15 18
     }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
6 6
 class Session
7 7
 {
8 8
 
9
-    public static function put($key, $value){
9
+    public static function put($key, $value) {
10 10
         $_SESSION[$key] = $value;
11 11
     }
12 12
 
13
-    public static function get($key){
13
+    public static function get($key) {
14 14
         return (isset($_SESSION[$key]) ? $_SESSION[$key] : null);
15 15
     }
16 16
 
17
-    public static function forget($key){
17
+    public static function forget($key) {
18 18
         unset($_SESSION[$key]);
19 19
     }
20 20
 
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once (__DIR__ . '/vendor/autoload.php');
3
+require_once (__DIR__.'/vendor/autoload.php');
4 4
 use ChatApp\Session;
5 5
 use Dotenv\Dotenv;
6 6
 $dotenv = new Dotenv(__DIR__);
7 7
 $dotenv->load();
8 8
 
9 9
 // die("Hello");
10
-if(Session::get('start') != null)
10
+if (Session::get('start') != null)
11 11
 {
12 12
     header("Location:".getenv('APP_URL')."/views/account.php");
13 13
 }
Please login to merge, or discard this patch.
src/Receiver.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -24,6 +24,10 @@
 block discarded – undo
24 24
         $this->conversation = new Conversation();
25 25
     }
26 26
 
27
+    /**
28
+     * @param string $msg
29
+     * @param boolean $para
30
+     */
27 31
     public function receiverLoad($msg, $para)
28 32
     {
29 33
         $msg = json_decode($msg);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         $msg = json_encode($msg);
37 37
         $this->messages = json_decode($this->conversation->conversationLoad($msg, $para));
38 38
         // $id1 = json_decode($msg)->details;
39
-        for ($i = 1 ; $i < count($this->messages); $i++) {
39
+        for ($i = 1; $i < count($this->messages); $i++) {
40 40
             $this->messages[$i]->start = $id1;
41 41
         }
42 42
         $id2 = bin2hex(convert_uuencode($id2));
Please login to merge, or discard this patch.
views/account.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
                         <div class="brief">
66 66
                             <h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
67 67
                             <?php foreach ($row as $key => $value) {
68
-                                if ($key =='username' && $value != null) {
68
+                                if ($key == 'username' && $value != null) {
69 69
                                     echo '<p>Username: '.$row["username"].'</p><br>';
70 70
                                 }
71 71
                                 if ($key == 'email' && $value != null) {
Please login to merge, or discard this patch.