Completed
Pull Request — master (#164)
by Corey
03:18
created

UserTest   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 947
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 17
dl 0
loc 947
rs 9.7391
c 0
b 0
f 0

17 Methods

Rating   Name   Duplication   Size   Complexity  
B setUp() 0 41 1
A testIsTokenCurrent() 0 11 1
A tearDown() 0 3 1
A testParseBehaviorData() 0 4 1
A testIsTokenConfirmed() 0 4 1
A testIsOverThreshold() 0 10 1
A testParseQuestionData() 0 4 1
A testIsPartnerEnabled() 0 22 1
A testGetIdHash() 0 9 1
A testGenerateVerifyEmailToken() 0 4 1
A testConfirmVerifyEmailToken() 0 4 1
A testIsVerified() 0 7 1
A testGenerateChangeEmailToken() 0 4 1
A testRemoveVerifyEmailToken() 0 4 1
B testCleanExportData() 0 46 1
A testRemoveChangeEmailToken() 0 4 1
A testGeneratePasswordResetToken() 0 4 1
1
<?php
2
3
namespace common\unit\models;
4
5
use Yii;
6
use Codeception\Specify;
7
use common\models\User;
8
9
date_default_timezone_set('UTC');
10
11
/**
12
 * User test
13
 */
14
15
class UserTest extends \Codeception\Test\Unit {
16
  use Specify;
17
18
  private $user;
19
20
	public $questionData = [
21
	[
22
		'id' => 641,
23
		'user_id' => 2,
24
		'behavior_id' => 13,
25
		'user_behavior_id' => 821,
26
		'question' => 1,
27
		'answer' => 'alsgn',
28
		'date' => '2016-09-10 19:27:43',
29
		'behavior' => 
30
		[
31
			'id' => 13,
32
			'name' => 'less time/energy for God, meetings, and church',
33
			'category_id' => 2,
34
		],
35
	],
36
	[
37
		'id' => 642,
38
		'user_id' => 2,
39
		'behavior_id' => 13,
40
		'user_behavior_id' => 821,
41
		'question' => 2,
42
		'answer' => 'loiun',
43
		'date' => '2016-09-10 19:27:43',
44
		'behavior' => 
45
		[
46
			'id' => 13,
47
			'name' => 'less time/energy for God, meetings, and church',
48
			'category_id' => 2,
49
		],
50
	],
51
	[
52
		'id' => 643,
53
		'user_id' => 2,
54
		'behavior_id' => 13,
55
		'user_behavior_id' => 821,
56
		'question' => 3,
57
		'answer' => 'liun',
58
		'date' => '2016-09-10 19:27:43',
59
		'behavior' => 
60
		[
61
			'id' => 13,
62
			'name' => 'less time/energy for God, meetings, and church',
63
			'category_id' => 2,
64
		],
65
	],
66
	[
67
		'id' => 644,
68
		'user_id' => 2,
69
		'behavior_id' => 29,
70
		'user_behavior_id' => 823,
71
		'question' => 1,
72
		'answer' => 'ljnb',
73
		'date' => '2016-09-10 19:27:43',
74
		'behavior' => 
75
		[
76
			'id' => 29,
77
			'name' => 'using profanity',
78
			'category_id' => 3,
79
		],
80
	],
81
	[
82
		'id' => 645,
83
		'user_id' => 2,
84
		'behavior_id' => 29,
85
		'user_behavior_id' => 823,
86
		'question' => 2,
87
		'answer' => 'liunb',
88
		'date' => '2016-09-10 19:27:43',
89
		'behavior' => 
90
		[
91
			'id' => 29,
92
			'name' => 'using profanity',
93
			'category_id' => 3,
94
		],
95
	],
96
	[
97
		'id' => 646,
98
		'user_id' => 2,
99
		'behavior_id' => 29,
100
		'user_behavior_id' => 823,
101
		'question' => 3,
102
		'answer' => 'ilub ',
103
		'date' => '2016-09-10 19:27:43',
104
		'behavior' => 
105
		[
106
			'id' => 29,
107
			'name' => 'using profanity',
108
			'category_id' => 3,
109
		],
110
	],
111
	[
112
		'id' => 647,
113
		'user_id' => 2,
114
		'behavior_id' => 48,
115
		'user_behavior_id' => 825,
116
		'question' => 1,
117
		'answer' => 'liub',
118
		'date' => '2016-09-10 19:27:43',
119
		'behavior' => 
120
		[
121
			'id' => 48,
122
			'name' => 'workaholic',
123
			'category_id' => 4,
124
		],
125
	],
126
	[
127
		'id' => 648,
128
		'user_id' => 2,
129
		'behavior_id' => 48,
130
		'user_behavior_id' => 825,
131
		'question' => 2,
132
		'answer' => 'liub',
133
		'date' => '2016-09-10 19:27:43',
134
		'behavior' => 
135
		[
136
			'id' => 48,
137
			'name' => 'workaholic',
138
			'category_id' => 4,
139
		],
140
	],
141
	[
142
		'id' => 649,
143
		'user_id' => 2,
144
		'behavior_id' => 48,
145
		'user_behavior_id' => 825,
146
		'question' => 3,
147
		'answer' => 'liub ',
148
		'date' => '2016-09-10 19:27:43',
149
		'behavior' => 
150
		[
151
			'id' => 48,
152
			'name' => 'workaholic',
153
			'category_id' => 4,
154
		],
155
	],
156
	[
157
		'id' => 650,
158
		'user_id' => 2,
159
		'behavior_id' => 89,
160
		'user_behavior_id' => 828,
161
		'question' => 1,
162
		'answer' => 'liub',
163
		'date' => '2016-09-10 19:27:43',
164
		'behavior' => 
165
		[
166
			'id' => 89,
167
			'name' => 'obsessive (stuck) thoughts',
168
			'category_id' => 5,
169
		],
170
	],
171
	[
172
		'id' => 651,
173
		'user_id' => 2,
174
		'behavior_id' => 89,
175
		'user_behavior_id' => 828,
176
		'question' => 2,
177
		'answer' => 'liuby',
178
		'date' => '2016-09-10 19:27:43',
179
		'behavior' => 
180
		[
181
			'id' => 89,
182
			'name' => 'obsessive (stuck) thoughts',
183
			'category_id' => 5,
184
		],
185
	],
186
	[
187
		'id' => 652,
188
		'user_id' => 2,
189
		'behavior_id' => 89,
190
		'user_behavior_id' => 828,
191
		'question' => 3,
192
		'answer' => 'uiylb',
193
		'date' => '2016-09-10 19:27:43',
194
		'behavior' => 
195
		[
196
			'id' => 89,
197
			'name' => 'obsessive (stuck) thoughts',
198
			'category_id' => 5,
199
		],
200
	],
201
	[
202
		'id' => 653,
203
		'user_id' => 2,
204
		'behavior_id' => 111,
205
		'user_behavior_id' => 829,
206
		'question' => 1,
207
		'answer' => 'liub',
208
		'date' => '2016-09-10 19:27:43',
209
		'behavior' => 
210
		[
211
			'id' => 111,
212
			'name' => 'seeking out old unhealthy people and places',
213
			'category_id' => 6,
214
		],
215
	],
216
	[
217
		'id' => 654,
218
		'user_id' => 2,
219
		'behavior_id' => 111,
220
		'user_behavior_id' => 829,
221
		'question' => 2,
222
		'answer' => 'liuyb',
223
		'date' => '2016-09-10 19:27:43',
224
		'behavior' => 
225
		[
226
			'id' => 111,
227
			'name' => 'seeking out old unhealthy people and places',
228
			'category_id' => 6,
229
		],
230
	],
231
	[
232
		'id' => 655,
233
		'user_id' => 2,
234
		'behavior_id' => 111,
235
		'user_behavior_id' => 829,
236
		'question' => 3,
237
		'answer' => 'iuyb',
238
		'date' => '2016-09-10 19:27:43',
239
		'behavior' => 
240
		[
241
			'id' => 111,
242
			'name' => 'seeking out old unhealthy people and places',
243
			'category_id' => 6,
244
		],
245
	],
246
	[
247
		'id' => 656,
248
		'user_id' => 2,
249
		'behavior_id' => 122,
250
		'user_behavior_id' => 831,
251
		'question' => 1,
252
		'answer' => 'iuyb',
253
		'date' => '2016-09-10 19:27:43',
254
		'behavior' => 
255
		[
256
			'id' => 122,
257
			'name' => 'returning to the place you swore you would never go again',
258
			'category_id' => 7,
259
		],
260
	],
261
	[
262
		'id' => 657,
263
		'user_id' => 2,
264
		'behavior_id' => 122,
265
		'user_behavior_id' => 831,
266
		'question' => 2,
267
		'answer' => 'iuyb',
268
		'date' => '2016-09-10 19:27:43',
269
		'behavior' => 
270
		[
271
			'id' => 122,
272
			'name' => 'returning to the place you swore you would never go again',
273
			'category_id' => 7,
274
		],
275
	],
276
	[
277
		'id' => 658,
278
		'user_id' => 2,
279
		'behavior_id' => 122,
280
		'user_behavior_id' => 831,
281
		'question' => 3,
282
		'answer' => 'liuyb',
283
		'date' => '2016-09-10 19:27:43',
284
		'behavior' => 
285
		[
286
			'id' => 122,
287
			'name' => 'returning to the place you swore you would never go again',
288
			'category_id' => 7,
289
		],
290
	],
291
];
292
public $userQuestions = [
293
	13 => [
294
		'question' => [
295
			'id' => 13,
296
			'title' => 'less time/energy for God, meetings, and church',
297
		],
298
		'answers' => [
299
			[
300
				'title' => 'How does it affect me? How do I act and feel?',
301
				'answer' => 'alsgn',
302
			], [
303
				'title' => 'How does it affect the important people in my life?',
304
				'answer' => 'loiun',
305
			], [
306
				'title' => 'Why do I do this? What is the benefit for me?',
307
				'answer' => 'liun',
308
			],
309
		],
310
	],
311
	29 => [
312
		'question' => [
313
			'id' => 29,
314
			'title' => 'using profanity',
315
		],
316
		'answers' => [
317
			[
318
				'title' => 'How does it affect me? How do I act and feel?',
319
				'answer' => 'ljnb',
320
			], [
321
				'title' => 'How does it affect the important people in my life?',
322
				'answer' => 'liunb',
323
			], [
324
				'title' => 'Why do I do this? What is the benefit for me?',
325
				'answer' => 'ilub ',
326
			],
327
		],
328
	],
329
	48 => [
330
		'question' => [
331
			'id' => 48,
332
			'title' => 'workaholic',
333
		],
334
		'answers' => [
335
			[
336
				'title' => 'How does it affect me? How do I act and feel?',
337
				'answer' => 'liub',
338
			], [
339
				'title' => 'How does it affect the important people in my life?',
340
				'answer' => 'liub',
341
			], [
342
				'title' => 'Why do I do this? What is the benefit for me?',
343
				'answer' => 'liub ',
344
			],
345
		],
346
	],
347
	89 => [
348
		'question' => [
349
			'id' => 89,
350
			'title' => 'obsessive (stuck) thoughts',
351
		],
352
		'answers' => [
353
			[
354
				'title' => 'How does it affect me? How do I act and feel?',
355
				'answer' => 'liub',
356
			], [
357
				'title' => 'How does it affect the important people in my life?',
358
				'answer' => 'liuby',
359
			], [
360
				'title' => 'Why do I do this? What is the benefit for me?',
361
				'answer' => 'uiylb',
362
			],
363
		],
364
	],
365
	111 => [
366
		'question' => [
367
			'id' => 111,
368
			'title' => 'seeking out old unhealthy people and places',
369
		],
370
		'answers' => [
371
			[
372
				'title' => 'How does it affect me? How do I act and feel?',
373
				'answer' => 'liub',
374
			], [
375
				'title' => 'How does it affect the important people in my life?',
376
				'answer' => 'liuyb',
377
			], [
378
				'title' => 'Why do I do this? What is the benefit for me?',
379
				'answer' => 'iuyb',
380
			],
381
		],
382
	],
383
	122 => [
384
		'question' => [
385
			'id' => 122,
386
			'title' => 'returning to the place you swore you would never go again',
387
		],
388
		'answers' => [
389
			[
390
				'title' => 'How does it affect me? How do I act and feel?',
391
				'answer' => 'iuyb',
392
			], [
393
				'title' => 'How does it affect the important people in my life?',
394
				'answer' => 'iuyb',
395
			], [
396
				'title' => 'Why do I do this? What is the benefit for me?',
397
				'answer' => 'liuyb',
398
			],
399
		],
400
	],
401
];
402
403
public $behaviorData = [
404
	[
405
		'id' => 820,
406
		'user_id' => 2,
407
		'behavior_id' => 7,
408
		'date' => '2016-09-10 19:26:04',
409
		'behavior' => [
410
			'id' => 7,
411
			'name' => 'making eye contact',
412
			'category_id' => 1,
413
			'category' => [
414
				'id' => 1,
415
				'name' => 'Restoration',
416
				'weight' => '0',
417
			],
418
		],
419
	], [
420
		'id' => 821,
421
		'user_id' => 2,
422
		'behavior_id' => 13,
423
		'date' => '2016-09-10 19:26:04',
424
		'behavior' => [
425
			'id' => 13,
426
			'name' => 'less time/energy for God, meetings, and church',
427
			'category_id' => 2,
428
			'category' => [
429
				'id' => 2,
430
				'name' => 'Forgetting Priorities',
431
				'weight' => '0.016',
432
			],
433
		],
434
	], [
435
		'id' => 822,
436
		'user_id' => 2,
437
		'behavior_id' => 18,
438
		'date' => '2016-09-10 19:26:04',
439
		'behavior' => [
440
			'id' => 18,
441
			'name' => 'changes in goals',
442
			'category_id' => 2,
443
			'category' => [
444
				'id' => 2,
445
				'name' => 'Forgetting Priorities',
446
				'weight' => '0.016',
447
			],
448
		],
449
	], [
450
		'id' => 823,
451
		'user_id' => 2,
452
		'behavior_id' => 29,
453
		'date' => '2016-09-10 19:26:04',
454
		'behavior' => [
455
			'id' => 29,
456
			'name' => 'using profanity',
457
			'category_id' => 3,
458
			'category' => [
459
				'id' => 3,
460
				'name' => 'Anxiety',
461
				'weight' => '0.032',
462
			],
463
		],
464
	], [
465
		'id' => 824,
466
		'user_id' => 2,
467
		'behavior_id' => 41,
468
		'date' => '2016-09-10 19:26:04',
469
		'behavior' => [
470
			'id' => 41,
471
			'name' => 'co-dependent rescuing',
472
			'category_id' => 3,
473
			'category' => [
474
				'id' => 3,
475
				'name' => 'Anxiety',
476
				'weight' => '0.032',
477
			],
478
		],
479
	], [
480
		'id' => 825,
481
		'user_id' => 2,
482
		'behavior_id' => 48,
483
		'date' => '2016-09-10 19:26:04',
484
		'behavior' => [
485
			'id' => 48,
486
			'name' => 'workaholic',
487
			'category_id' => 4,
488
			'category' => [
489
				'id' => 4,
490
				'name' => 'Speeding Up',
491
				'weight' => '0.064',
492
			],
493
		],
494
	], [
495
		'id' => 826,
496
		'user_id' => 2,
497
		'behavior_id' => 72,
498
		'date' => '2016-09-10 19:26:04',
499
		'behavior' => [
500
			'id' => 72,
501
			'name' => 'black and white, all or nothing thinking',
502
			'category_id' => 5,
503
			'category' => [
504
				'id' => 5,
505
				'name' => 'Ticked Off',
506
				'weight' => '0.128',
507
			],
508
		],
509
	], [
510
		'id' => 827,
511
		'user_id' => 2,
512
		'behavior_id' => 79,
513
		'date' => '2016-09-10 19:26:04',
514
		'behavior' => [
515
			'id' => 79,
516
			'name' => 'blaming',
517
			'category_id' => 5,
518
			'category' => [
519
				'id' => 5,
520
				'name' => 'Ticked Off',
521
				'weight' => '0.128',
522
			],
523
		],
524
	], [
525
		'id' => 828,
526
		'user_id' => 2,
527
		'behavior_id' => 89,
528
		'date' => '2016-09-10 19:26:04',
529
		'behavior' => [
530
			'id' => 89,
531
			'name' => 'obsessive (stuck) thoughts',
532
			'category_id' => 5,
533
			'category' => [
534
				'id' => 5,
535
				'name' => 'Ticked Off',
536
				'weight' => '0.128',
537
			],
538
		],
539
	], [
540
		'id' => 829,
541
		'user_id' => 2,
542
		'behavior_id' => 111,
543
		'date' => '2016-09-10 19:26:04',
544
		'behavior' => [
545
			'id' => 111,
546
			'name' => 'seeking out old unhealthy people and places',
547
			'category_id' => 6,
548
			'category' => [
549
				'id' => 6,
550
				'name' => 'Exhausted',
551
				'weight' => '0.256',
552
			],
553
		],
554
	], [
555
		'id' => 830,
556
		'user_id' => 2,
557
		'behavior_id' => 118,
558
		'date' => '2016-09-10 19:26:04',
559
		'behavior' => [
560
			'id' => 118,
561
			'name' => 'not returning phone calls',
562
			'category_id' => 6,
563
			'category' => [
564
				'id' => 6,
565
				'name' => 'Exhausted',
566
				'weight' => '0.256',
567
			],
568
		],
569
	], [
570
		'id' => 831,
571
		'user_id' => 2,
572
		'behavior_id' => 122,
573
		'date' => '2016-09-10 19:26:04',
574
		'behavior' => [
575
			'id' => 122,
576
			'name' => 'returning to the place you swore you would never go again',
577
			'category_id' => 7,
578
			'category' => [
579
				'id' => 7,
580
				'name' => 'Relapse/Moral Failure',
581
				'weight' => '0.512',
582
			],
583
		],
584
	],
585
];
586
587
public $userBehaviors = [
588
	1 => [
589
		'category_name' => 'Restoration',
590
		'behaviors' => [
591
			[
592
				'id' => 7,
593
				'name' => 'making eye contact',
594
			],
595
		],
596
	],
597
	2 => [
598
		'category_name' => 'Forgetting Priorities',
599
		'behaviors' => [
600
			[
601
				'id' => 13,
602
				'name' => 'less time/energy for God, meetings, and church',
603
			], [
604
				'id' => 18,
605
				'name' => 'changes in goals',
606
			],
607
		],
608
  ],
609
  3 => [
610
		'category_name' => 'Anxiety',
611
		'behaviors' => [
612
			[
613
				'id' => 29,
614
				'name' => 'using profanity',
615
			], [
616
				'id' => 41,
617
				'name' => 'co-dependent rescuing',
618
			],
619
		],
620
	],
621
	4 => [
622
		'category_name' => 'Speeding Up',
623
		'behaviors' => [
624
			[
625
				'id' => 48,
626
				'name' => 'workaholic',
627
			],
628
		],
629
	],
630
	5 => [
631
		'category_name' => 'Ticked Off',
632
		'behaviors' => [
633
			[
634
				'id' => 72,
635
				'name' => 'black and white, all or nothing thinking',
636
			], [
637
				'id' => 79,
638
				'name' => 'blaming',
639
			], [
640
				'id' => 89,
641
				'name' => 'obsessive (stuck) thoughts',
642
			],
643
		],
644
	],
645
	6 => [
646
		'category_name' => 'Exhausted',
647
		'behaviors' => [
648
			[
649
				'id' => 111,
650
				'name' => 'seeking out old unhealthy people and places',
651
			], [
652
				'id' => 118,
653
				'name' => 'not returning phone calls',
654
			],
655
		],
656
	],
657
	7 => [
658
		'category_name' => 'Relapse/Moral Failure',
659
		'behaviors' => [
660
			[
661
				'id' => 122,
662
				'name' => 'returning to the place you swore you would never go again',
663
			],
664
		],
665
	],
666
];
667
668
public $exportData = [
669
    [
670
      'id' => 485,
671
      'date' => '2017-07-29 10:40:29',
672
      'behavior_id' => 59,
673
      'question1' => 'q1',
674
      'question2' => 'q2',
675
      'question3' => 'q3',
676
      'behavior' => [
677
        'id' => 59,
678
        'name' => 'repetitive, negative thoughts',
679
        'category_id' => 4,
680
        'category' => [
681
          'id' => 4,
682
          'name' => 'Speeding Up',
683
          'weight' => 4,
684
        ],
685
      ],
686
    ], [
687
      'id' => 487,
688
      'date' => '2017-07-29 10:40:29',
689
      'behavior_id' => 106,
690
      'question1' => 'q1',
691
      'question2' => 'q2',
692
      'question3' => 'q3',
693
      'behavior' => [
694
        'id' => 106,
695
        'name' => 'tired',
696
        'category_id' => 6,
697
        'category' => [
698
          'id' => 6,
699
          'name' => 'Exhausted',
700
          'weight' => 8,
701
        ],
702
      ],
703
    ], [
704
      'id' => 488,
705
      'date' => '2017-07-29 10:40:29',
706
      'behavior_id' => 125,
707
      'question1' => 'q1',
708
      'question2' => 'q2',
709
      'question3' => 'q3',
710
      'behavior' => [
711
        'id' => 125,
712
        'name' => 'out of control',
713
        'category_id' => 7,
714
        'category' => [
715
          'id' => 7,
716
          'name' => 'Relapse/Moral Failure',
717
          'weight' => 10,
718
        ],
719
      ],
720
    ], [
721
      'id' => 486,
722
      'date' => '2017-07-29 10:40:29',
723
      'behavior_id' => 89,
724
      'question1' => 'q1',
725
      'question2' => 'q2',
726
      'question3' => 'q3',
727
      'behavior' => [
728
        'id' => 89,
729
        'name' => 'obsessive (stuck) thoughts',
730
        'category_id' => 5,
731
        'category' => [
732
          'id' => 5,
733
          'name' => 'Ticked Off',
734
          'weight' => 6,
735
        ],
736
      ],
737
    ]
738
  ];
739
740
  public function setUp() {
741
    $this->container = new \yii\di\Container;
0 ignored issues
show
Bug Best Practice introduced by
The property container does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
742
    $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
743
    $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
744
    $this->container->set('common\interfaces\TimeInterface', function () {
745
      return new \common\components\Time('America/Los_Angeles');
746
    });
747
748
    $user_behavior = $this->container->get('common\interfaces\UserBehaviorInterface');
749
    $time          = $this->container->get('common\interfaces\TimeInterface');
750
751
    $question = $this->getMockBuilder('\common\models\Question')
752
      ->setMethods(['save', 'attributes'])
753
      ->getMock();
754
755
    $this->user = $this->getMockBuilder('\common\models\User')
756
      ->setConstructorArgs([$user_behavior, $question, $time])
757
      ->setMethods(['save', 'attributes'])
758
      ->getMock();
759
    $this->user->method('save')->willReturn(true);
0 ignored issues
show
Bug introduced by
The method method() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

759
    $this->user->/** @scrutinizer ignore-call */ 
760
                 method('save')->willReturn(true);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
760
    $this->user->method('attributes')->willReturn([
761
      'id',
762
      'password_hash',
763
      'password_reset_token',
764
      'verify_email_token',
765
      'change_email_token',
766
      'email',
767
      'auth_key',
768
      'role',
769
      'status',
770
      'created_at',
771
      'updated_at',
772
      'password',
773
      'timezone',
774
      'email_threshold',
775
      'partner_email1',
776
      'partner_email2',
777
      'partner_email3',
778
    ]);
779
780
    parent::setUp();
781
  }
782
783
  protected function tearDown() {
784
    $this->user = null;
785
    parent::tearDown();
786
  }
787
788
  public function testParseQuestionData() {
789
    $this->specify('parseQuestionData should function correctly', function () {
790
      expect('parseQuestionData should return the correct structure with expected data', $this->assertEquals($this->user->parseQuestionData($this->questionData), $this->userQuestions));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals($thi..., $this->userQuestions) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
791
      expect('parseQuestionData should return empty with the empty set', $this->assertEmpty($this->user->parseQuestionData([])));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEmpty($this...eQuestionData(array())) targeting PHPUnit\Framework\Assert::assertEmpty() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
792
    });
793
  }
794
795
  public function testParseBehaviorData() {
796
    $this->specify('parseBehaviorData should function correctly', function () {
797
      expect('parseBehaviorData should return the correct structure with expected data', $this->assertEquals($this->user->parseBehaviorData($this->behaviorData), $this->userBehaviors));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals($thi..., $this->userBehaviors) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
798
      expect('parseBehaviorData should return empty with the empty set', $this->assertEmpty($this->user->parseBehaviorData([])));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEmpty($this...eBehaviorData(array())) targeting PHPUnit\Framework\Assert::assertEmpty() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
799
    });
800
  }
801
802
  public function testIsPartnerEnabled() {
803
    $this->specify('isPartnerEnabled should function correctly', function () {
804
      expect('isPartnerEnabled should return false when no partners are set and email_threshold is null', $this->assertFalse($this->user->isPartnerEnabled()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...er->isPartnerEnabled()) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
805
806
      $this->user->email_threshold = 10;
807
      expect('isPartnerEnabled should return false when no partners are set and email_threshold is a positive integer', $this->assertFalse($this->user->isPartnerEnabled()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...er->isPartnerEnabled()) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
808
809
      $this->user->partner_email3 = '[email protected]';
810
      $this->user->email_threshold = null;
811
      expect('isPartnerEnabled should return false when a partner is set and email_threshold is null', $this->assertFalse($this->user->isPartnerEnabled()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...er->isPartnerEnabled()) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
812
813
      $this->user->email_threshold = 10;
814
      expect('isPartnerEnabled should return true when at one partner is set and email_threshold is a positive integer', $this->assertTrue($this->user->isPartnerEnabled()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($this-...er->isPartnerEnabled()) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
815
816
      $this->user->partner_email1 = '[email protected]';
817
      expect('isPartnerEnabled should return true when two partners are set and email_threshold is a positive integer', $this->assertTrue($this->user->isPartnerEnabled()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($this-...er->isPartnerEnabled()) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
818
819
      $this->user->email_threshold = 0;
820
      expect('isPartnerEnabled should return true when two partners are set and email_threshold is 0', $this->assertTrue($this->user->isPartnerEnabled()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($this-...er->isPartnerEnabled()) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
821
822
      $this->user->email_threshold = -7;
823
      expect('isPartnerEnabled should return false when two partners are set and email_threshold is a negative number', $this->assertFalse($this->user->isPartnerEnabled()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...er->isPartnerEnabled()) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
824
    });
825
  }
826
827
  public function testIsOverThreshold() {
828
    $this->specify('isOverThreshold should function correctly', function () {
829
      expect('isOverThreshold should return false with no partners enabled', $this->assertFalse($this->user->isOverThreshold(5)));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...er->isOverThreshold(5)) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
830
831
      $this->user->email_threshold = 10;
832
      $this->user->partner_email1 = '[email protected]';
833
      expect('isOverThreshold should return false if partners enabled but not over threshold', $this->assertFalse($this->user->isOverThreshold(5)));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...er->isOverThreshold(5)) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
834
      expect('isOverThreshold should return false if partners enabled and equal to but not over threshold', $this->assertFalse($this->user->isOverThreshold(10)));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...r->isOverThreshold(10)) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
835
836
      expect('isOverThreshold should return true if partners enabled and over threshold', $this->assertTrue($this->user->isOverThreshold(15)));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($this-...r->isOverThreshold(15)) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
837
    });
838
  }
839
840
  public function testIsTokenCurrent() {
841
    $this->specify('isTokenCurrent should function correctly', function () {
842
      $good_token = \Yii::$app
843
                      ->getSecurity()
844
                      ->generateRandomString() . '_' . time();
845
      expect('isTokenCurrent should return true if the token is still current/alive', $this->assertTrue($this->user->isTokenCurrent($good_token)));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($this-...enCurrent($good_token)) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
846
      $expire = \Yii::$app->params['user.passwordResetTokenExpire'];
847
      $bad_token = \Yii::$app
848
                      ->getSecurity()
849
                      ->generateRandomString() . '_' . (time() - $expire - 1); // subtract the expiration time and a little more from the current time
850
      expect('isTokenCurrent should return false if the token is expired', $this->assertFalse($this->user->isTokenCurrent($bad_token)));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...kenCurrent($bad_token)) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
851
    });
852
  }
853
854
  public function testIsTokenConfirmed() {
855
      expect('isTokenConfirmed should return true if the token has been confirmed', $this->assertTrue($this->user->isTokenConfirmed('token123_confirmed')));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($this-...('token123_confirmed')) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
856
      expect('isTokenConfirmed should return false if the token has not been confirmed', $this->assertFalse($this->user->isTokenConfirmed('token123')));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...nConfirmed('token123')) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
857
      expect('isTokenConfirmed should return false if the token has not been confirmed', $this->assertFalse($this->user->isTokenConfirmed('token123_not_blah')));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this...d('token123_not_blah')) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
858
  }
859
860
  public function testGeneratePasswordResetToken() {
861
    expect('password_reset_token should be null by default', $this->assertNull($this->user->password_reset_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertNull($this-...->password_reset_token) targeting PHPUnit\Framework\Assert::assertNull() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
862
    $this->user->generatePasswordResetToken();
863
    expect('password_reset_token should now have a verification token set', $this->assertRegExp('/.*_[0-9]+/', $this->user->password_reset_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertRegExp('/.*...->password_reset_token) targeting PHPUnit\Framework\Assert::assertRegExp() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
864
  }
865
866
  public function testGenerateVerifyEmailToken() {
867
    expect('verify_email_token should be null by default', $this->assertNull($this->user->verify_email_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertNull($this-...er->verify_email_token) targeting PHPUnit\Framework\Assert::assertNull() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
868
    $this->user->generateVerifyEmailToken();
869
    expect('verify_email_token should now have a verification token set', $this->assertRegExp('/.*_[0-9]+/', $this->user->verify_email_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertRegExp('/.*...er->verify_email_token) targeting PHPUnit\Framework\Assert::assertRegExp() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
870
  }
871
872
  public function testConfirmVerifyEmailToken() {
873
    $this->user->verify_email_token = 'hello_world';
874
    $this->user->confirmVerifyEmailToken();
875
    expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world'.$this->user::CONFIRMED_STRING));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals($thi...user::CONFIRMED_STRING) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
876
  }
877
878
  public function testIsVerified() {
879
      $this->user->verify_email_token = null;
880
      expect('isVerified should return true if the token is null', $this->assertTrue($this->user->isVerified()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($this->user->isVerified()) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
881
      $this->user->verify_email_token = '';
882
      expect('isVerified should return false if the token is the empty string', $this->assertFalse($this->user->isVerified()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this->user->isVerified()) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
883
      $this->user->verify_email_token = 'this_looks_truthy';
884
      expect('isVerified should return false if the token is still present', $this->assertFalse($this->user->isVerified()));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($this->user->isVerified()) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
885
  }
886
887
  public function testRemoveVerifyEmailToken() {
888
      $this->user->verify_email_token = 'faketoken_1234';
889
      $this->user->removeVerifyEmailToken();
890
      expect('removeVerifyEmailToken should set the verify_email_token to be null', $this->assertNull($this->user->verify_email_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertNull($this-...er->verify_email_token) targeting PHPUnit\Framework\Assert::assertNull() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
891
  }
892
893
  public function testGetIdHash() {
894
    $hash = 'iegYQgiPZUF48kk5bneuPn9_6ZOZhkMEGJ6Y8yICgKc';
895
896
    $this->user->id = 12345;
897
    $this->user->created_at = "2017-12-31 23:59:59";
898
    expect('getIdHash should return a url-safe string', $this->assertEquals($this->user->getidHash(), $hash));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals($thi...er->getidHash(), $hash) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
899
900
    $this->user->created_at = "2018-01-01 00:00:00";
901
    expect('getIdHash should return a DIFFERENT url-safe string for different params', $this->assertNotEquals($this->user->getidHash(), $hash));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertNotEquals($...er->getidHash(), $hash) targeting PHPUnit\Framework\Assert::assertNotEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
902
  }
903
904
  public function testCleanExportData() {
905
    // need this for the convertUTCToLocal call
906
    Yii::configure(Yii::$app, [
907
      'components' => [
908
        'user' => [
909
          'class' => 'yii\web\User',
910
          'identityClass' => 'common\tests\unit\FakeUser',
911
        ],
912
      ],
913
    ]);
914
    $identity = new \common\tests\unit\FakeUser();
915
    $identity->timezone = "America/Los_Angeles";
916
    // logs in the user 
917
    Yii::$app->user->setIdentity($identity);
0 ignored issues
show
Bug introduced by
The method setIdentity() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

917
    Yii::$app->user->/** @scrutinizer ignore-call */ 
918
                     setIdentity($identity);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
918
919
    expect('cleanExportData should clean and mutate the queried data to be suitable for downloading', $this->assertEquals([
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals(arra...ata($this->exportData)) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
920
      [
921
        'date' => '2017-07-29 03:40:29',
922
        'behavior' => 'repetitive, negative thoughts',
923
        'category' => 'Speeding Up',
924
        'question1' => 'q1',
925
        'question2' => 'q2',
926
        'question3' => 'q3',
927
      ], [
928
        'date' => '2017-07-29 03:40:29',
929
        'behavior' => 'tired',
930
        'category' => 'Exhausted',
931
        'question1' => 'q1',
932
        'question2' => 'q2',
933
        'question3' => 'q3',
934
      ], [
935
        'date' => '2017-07-29 03:40:29',
936
        'behavior' => 'out of control',
937
        'category' => 'Relapse/Moral Failure',
938
        'question1' => 'q1',
939
        'question2' => 'q2',
940
        'question3' => 'q3',
941
      ], [
942
        'date' => '2017-07-29 03:40:29',
943
        'behavior' => 'obsessive (stuck) thoughts',
944
        'category' => 'Ticked Off',
945
        'question1' => 'q1',
946
        'question2' => 'q2',
947
        'question3' => 'q3',
948
      ]
949
    ], $this->user->cleanExportData($this->exportData)));
950
  }
951
952
  public function testGenerateChangeEmailToken() {
953
    expect('change_email_token should be null by default', $this->assertNull($this->user->change_email_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertNull($this-...er->change_email_token) targeting PHPUnit\Framework\Assert::assertNull() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
954
    $this->user->generateChangeEmailToken();
955
    expect('change_email_token should now have a verification token set', $this->assertRegExp('/.*_[0-9]+/', $this->user->change_email_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertRegExp('/.*...er->change_email_token) targeting PHPUnit\Framework\Assert::assertRegExp() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
956
  }
957
958
  public function testRemoveChangeEmailToken() {
959
      $this->user->change_email_token = 'faketoken_1234';
960
      $this->user->removeChangeEmailToken();
961
      expect('removeChangeEmailToken should set the change_email_token to be null', $this->assertNull($this->user->change_email_token));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertNull($this-...er->change_email_token) targeting PHPUnit\Framework\Assert::assertNull() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
962
  }
963
}
964