Completed
Push — master ( 96f5c0...6ce451 )
by Dmitry
03:33
created

Assert::expectExceptionObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PHPKitchen\CodeSpecs\Expectation\Internal;
4
5
use ArrayAccess;
6
use PHPUnit\Framework\Test;
7
8
/**
9
 * Represents PHPUnit Assert facade.
10
 *
11
 * Goal of this class is prepare assert messages according
12
 *
13
 * @codeCoverageIgnore
14
 *
15
 * @package PHPKitchen\CodeSpecs\Expectation\Internal
16
 * @author Dmitry Kolodko <[email protected]>
17
 */
18
class Assert {
19
    const IN_TIME_EXECUTION_STRATEGY = 1;
20
    const DELAYED_EXECUTION_STRATEGY = 2;
21
    /**
22
     * @var mixed actual value or variable that will be matched to expectations.
23
     */
24
    protected $actual;
25
    /**
26
     * @var StepsList list of steps that was made prior current assert.
27
     */
28
    protected $stepsList;
29
    /**
30
     * @var Test the test object.
31
     */
32
    protected $test;
33
    /**
34
     * @var string description of expectation. If expectation fails this description will be displayed in console.
35
     */
36
    protected $description;
37
    /**
38
     * @var \SplQueue list of steps that was delayed to be executed after definition.
39
     */
40
    protected $delayedAssertSteps;
41
    /**
42
     * @var int execution strategy. Either {@link DELAYED_EXECUTION_STRATEGY} or {@link IN_TIME_EXECUTION_STRATEGY}.
43
     * Identifies whether to run assert methods when they called or later(runtime matchers functionality)
44
     */
45
    protected $strategy;
46
    /**
47
     * @var string internal value that identifies current step name that would be added to {@link stepsList}
48
     */
49
    private $currentStepName = '';
50
51
    public function __construct(StepsList $stepsList, Test $test, $actual, $description = '', $strategy = self::IN_TIME_EXECUTION_STRATEGY) {
52
        $this->stepsList = $stepsList;
53
        $this->test = $test;
54
        $this->actual = $actual;
55
        $this->description = $description;
56
        $this->delayedAssertSteps = new \SplQueue();
57
        $this->strategy = $strategy;
58
    }
59
60
    public function __clone() {
61
        $this->delayedAssertSteps = clone $this->delayedAssertSteps;
62
    }
63
64
    //region --------------------------- OWN METHODS ----------------------------//
65
66
    public function getActualValue() {
67
        return $this->actual;
68
    }
69
70
    public function changeDescriptionTo($newDescription) {
71
        $this->description = $newDescription;
72
    }
73
74
    public function changeCurrentStepTo($stepName) {
75
        $this->currentStepName = $stepName;
76
    }
77
78
    public function switchToInTimeExecutionStrategy() {
79
        $this->strategy = self::IN_TIME_EXECUTION_STRATEGY;
80
    }
81
82
    public function switchToDelayedExecutionStrategy() {
83
        $this->strategy = self::DELAYED_EXECUTION_STRATEGY;
84
    }
85
86
    public function runStepsWithActualValue($actualValue) {
87
        if ($this->strategy === self::DELAYED_EXECUTION_STRATEGY) {
88
            return;
89
        }
90
        $this->actual = $actualValue;
91
        while (!$this->delayedAssertSteps->isEmpty()) {
92
            $step = $this->delayedAssertSteps->dequeue();
93
            array_push($step[1], $this->getMessageForAssert());
94
            array_unshift($step[1], $this->actual);
95
            $this->executeAssertMethod($step[0], $step[1], $step[2]);
96
        }
97
    }
98
99
    protected function callAssertMethod($method, $config = []) {
100
        $stepName = $this->currentStepName;
101
        if ($this->strategy === self::IN_TIME_EXECUTION_STRATEGY) {
102
            $this->executeAssertMethod($method, $config, $stepName);
103
        } else {
104
            $this->delayedAssertSteps->enqueue([$method, $config, $stepName]);
105
        }
106
    }
107
108
    protected function executeAssertMethod($method, $config, $stepName) {
109
        $this->registerExpectation($stepName);
110
        if (is_callable([$this->test, $method])) {
111
            call_user_func_array([
112
                $this->test,
113
                $method,
114
            ], $this->buildAssertMethodParamsFromConfig($config));
115
        } elseif (method_exists($this, $method)) {
116
            call_user_func_array([
117
                $this,
118
                $method,
119
            ], $this->buildAssertMethodParamsFromConfig($config));
120
        } else {
121
            throw new \InvalidArgumentException("Assert method '{$method}' does not exist");
122
        }
123
    }
124
125
    protected function buildAssertMethodParamsFromConfig($config) {
126
        $params = [];
127
        if (array_key_exists('expected', $config)) {
128
            $params[] = $config['expected'];
129
        }
130
        $params[] = $this->actual;
131
        if (isset($config['options'])) {
132
            $params = array_merge($params, $config['options']);
133
        }
134
135
        $params[] = $this->getMessageForAssert();
136
137
        if (isset($config['additionalParams'])) {
138
            $params = array_merge($params, $config['additionalParams']);
139
        }
140
141
        return $params;
142
    }
143
144
    protected function registerExpectation($message) {
145
        $this->stepsList->add("$this->description {$message}.");
146
    }
147
148
    protected function getMessageForAssert() {
149
        return $this->stepsList->convertToString();
150
    }
151
152
    //endregion
153
154
    /**
155
     * @param string $exception
156
     */
157
    public function expectException($exception) {
158
        $this->callAssertMethod(__FUNCTION__, [
159
            'expected' => $exception,
160
        ]);
161
    }
162
163
    /**
164
     * @param string $exception
165
     */
166
    public function expectExceptionObject($exceptionObject) {
167
        $this->callAssertMethod(__FUNCTION__, [
168
            'expected' => $exceptionObject,
169
        ]);
170
    }
171
172
    /**
173
     * @param int|string $code
174
     *
175
     * @throws \Exception
176
     */
177
    public function expectExceptionCode($code) {
178
        $this->callAssertMethod(__FUNCTION__, [
179
            'expected' => $code,
180
        ]);
181
    }
182
183
    /**
184
     * @param string $message
185
     *
186
     * @throws \Exception
187
     */
188
    public function expectExceptionMessage($message) {
189
        $this->callAssertMethod(__FUNCTION__, [
190
            'expected' => $message,
191
        ]);
192
    }
193
194
    /**
195
     * @param string $messageRegExp
196
     *
197
     * @throws \Exception
198
     */
199
    public function expectExceptionMessageRegExp($messageRegExp) {
200
        $this->callAssertMethod(__FUNCTION__, [
201
            'expected' => $messageRegExp,
202
        ]);
203
    }
204
205
    /**
206
     * Asserts that an array has a specified key.
207
     *
208
     * @param mixed $key
209
     */
210
    public function assertArrayHasKey($key) {
211
        $this->callAssertMethod(__FUNCTION__, [
212
            'expected' => $key,
213
        ]);
214
    }
215
216
    /**
217
     * Asserts that an array has a specified subset.
218
     *
219
     * @param array|ArrayAccess $subset
220
     */
221
    public function assertArraySubset($subset, $useStrictMatch) {
222
        $this->callAssertMethod(__FUNCTION__, [
223
            'expected' => $subset,
224
            'options' => [
225
                $useStrictMatch,
226
            ],
227
        ]);
228
    }
229
230
    /**
231
     * Asserts that an array does not have a specified key.
232
     *
233
     * @param mixed $key
234
     * @param array|ArrayAccess $array
235
     * @param string $message
236
     */
237
    public function assertArrayNotHasKey($key) {
238
        $this->callAssertMethod(__FUNCTION__, [
239
            'expected' => $key,
240
        ]);
241
    }
242
243
    /**
244
     * Asserts that a haystack contains a needle.
245
     *
246
     * @param mixed $needle
247
     * @param bool $ignoreCase
248
     * @param bool $checkForObjectIdentity
249
     * @param bool $checkForNonObjectIdentity
250
     */
251
    public function assertContains($needle, $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) {
252
        $this->callAssertMethod(__FUNCTION__, [
253
            'expected' => $needle,
254
            'additionalParams' => [
255
                $ignoreCase,
256
                $checkForObjectIdentity,
257
                $checkForNonObjectIdentity,
258
            ],
259
        ]);
260
    }
261
262
    /**
263
     * Asserts that a haystack does not contain a needle.
264
     *
265
     * @param mixed $needle
266
     * @param bool $ignoreCase
267
     * @param bool $checkForObjectIdentity
268
     * @param bool $checkForNonObjectIdentity
269
     */
270
    public function assertNotContains($needle, $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) {
271
        $this->callAssertMethod(__FUNCTION__, [
272
            'expected' => $needle,
273
            'additionalParams' => [
274
                $ignoreCase,
275
                $checkForObjectIdentity,
276
                $checkForNonObjectIdentity,
277
            ],
278
        ]);
279
    }
280
281
    /**
282
     * Asserts that a haystack contains only values of a given type.
283
     *
284
     * @param string $type
285
     * @param bool $isNativeType
286
     */
287
    public function assertContainsOnly($type, $isNativeType = null) {
288
        $this->callAssertMethod(__FUNCTION__, [
289
            'expected' => $type,
290
            'options' => [
291
                $isNativeType,
292
            ],
293
        ]);
294
    }
295
296
    /**
297
     * Asserts that a haystack does not contain only values of a given type.
298
     *
299
     * @param string $type
300
     * @param bool $isNativeType
301
     */
302
    public function assertNotContainsOnly($type, $isNativeType = null) {
303
        $this->callAssertMethod(__FUNCTION__, [
304
            'expected' => $type,
305
            'options' => [
306
                $isNativeType,
307
            ],
308
        ]);
309
    }
310
311
    /**
312
     * Asserts that a haystack that is stored in a static attribute of a class
313
     * or an attribute of an object contains a needle.
314
     *
315
     * @param mixed $needle
316
     * @param string $haystackAttributeName
317
     * @param string|object $haystackClassOrObject
318
     * @param string $message
319
     * @param bool $ignoreCase
320
     * @param bool $checkForObjectIdentity
321
     * @param bool $checkForNonObjectIdentity
322
     */
323
    public function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) {
324
        $this->callAssertMethod(__FUNCTION__, [
325
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
326
        ]);
327
    }
328
329
    /**
330
     * Asserts that a haystack that is stored in a static attribute of a class
331
     * or an attribute of an object does not contain a needle.
332
     *
333
     * @param mixed $needle
334
     * @param string $haystackAttributeName
335
     * @param string|object $haystackClassOrObject
336
     * @param string $message
337
     * @param bool $ignoreCase
338
     * @param bool $checkForObjectIdentity
339
     * @param bool $checkForNonObjectIdentity
340
     */
341
    public function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) {
342
        $this->callAssertMethod(__FUNCTION__, [
343
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
344
        ]);
345
    }
346
347
    /**
348
     * Asserts that a haystack contains only instances of a given classname
349
     *
350
     * @param string $className
351
     */
352
    public function assertContainsOnlyInstancesOf($className) {
353
        $this->callAssertMethod(__FUNCTION__, [
354
            'expected' => $className,
355
        ]);
356
    }
357
358
    /**
359
     * Asserts that a haystack that is stored in a static attribute of a class
360
     * or an attribute of an object contains only values of a given type.
361
     *
362
     * @param string $type
363
     * @param string $haystackAttributeName
364
     * @param string|object $haystackClassOrObject
365
     * @param bool $isNativeType
366
     * @param string $message
367
     */
368
    public function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null) {
369
        $this->callAssertMethod(__FUNCTION__, [
370
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
371
        ]);
372
    }
373
374
    /**
375
     * Asserts that a haystack that is stored in a static attribute of a class
376
     * or an attribute of an object does not contain only values of a given
377
     * type.
378
     *
379
     * @param string $type
380
     * @param string $haystackAttributeName
381
     * @param string|object $haystackClassOrObject
382
     * @param bool $isNativeType
383
     * @param string $message
384
     */
385
    public function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null) {
386
        $this->callAssertMethod(__FUNCTION__, [
387
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
388
        ]);
389
    }
390
391
    /**
392
     * Asserts the number of elements of an array, \Countable or \Traversable.
393
     *
394
     * @param int $expectedCount
395
     */
396
    public function assertCount($expectedCount) {
397
        $this->callAssertMethod(__FUNCTION__, [
398
            'expected' => $expectedCount,
399
        ]);
400
    }
401
402
    /**
403
     * Asserts the number of elements of an array, \Countable or \Traversable
404
     * that is stored in an attribute.
405
     *
406
     * @param int $expectedCount
407
     * @param string $haystackAttributeName
408
     * @param string|object $haystackClassOrObject
409
     * @param string $message
410
     */
411
    public function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject) {
412
        $this->callAssertMethod(__FUNCTION__, [
413
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
414
        ]);
415
    }
416
417
    /**
418
     * Asserts the number of elements of an array, \Countable or \Traversable.
419
     *
420
     * @param int $expectedCount
421
     * @param mixed $haystack
422
     * @param string $message
423
     */
424
    public function assertNotCount($expectedCount) {
425
        $this->callAssertMethod(__FUNCTION__, [
426
            'expected' => $expectedCount,
427
        ]);
428
    }
429
430
    /**
431
     * Asserts the number of elements of an array, \Countable or \Traversable
432
     * that is stored in an attribute.
433
     *
434
     * @param int $expectedCount
435
     * @param string $haystackAttributeName
436
     * @param string|object $haystackClassOrObject
437
     * @param string $message
438
     */
439
    public function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject) {
440
        $this->callAssertMethod(__FUNCTION__, [
441
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
442
        ]);
443
    }
444
445
    /**
446
     * Asserts that two variables are equal.
447
     *
448
     * @param mixed $expected
449
     * @param float $delta
450
     * @param int $maxDepth
451
     * @param bool $canonicalize
452
     * @param bool $ignoreCase
453
     */
454
    public function assertEquals($expected, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) {
455
        $this->callAssertMethod(__FUNCTION__, [
456
            'expected' => $expected,
457
            'additionalParams' => [
458
                $delta,
459
                $maxDepth,
460
                $canonicalize,
461
                $ignoreCase,
462
            ],
463
        ]);
464
    }
465
466
    /**
467
     * Asserts that a variable is equal to an attribute of an object.
468
     *
469
     * @param mixed $expected
470
     * @param string $actualAttributeName
471
     * @param string|object $actualClassOrObject
472
     * @param string $message
473
     * @param float $delta
474
     * @param int $maxDepth
475
     * @param bool $canonicalize
476
     * @param bool $ignoreCase
477
     */
478
    public function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) {
479
        $this->callAssertMethod(__FUNCTION__, [
480
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
481
        ]);
482
    }
483
484
    /**
485
     * Asserts that two variables are not equal.
486
     *
487
     * @param mixed $expected
488
     * @param float $delta
489
     * @param int $maxDepth
490
     * @param bool $canonicalize
491
     * @param bool $ignoreCase
492
     */
493
    public function assertNotEquals($expected, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) {
494
        $this->callAssertMethod(__FUNCTION__, [
495
            'expected' => $expected,
496
            'additionalParams' => [
497
                $delta,
498
                $maxDepth,
499
                $canonicalize,
500
                $ignoreCase,
501
            ],
502
        ]);
503
    }
504
505
    /**
506
     * Asserts that a variable is not equal to an attribute of an object.
507
     *
508
     * @param mixed $expected
509
     * @param string $actualAttributeName
510
     * @param string|object $actualClassOrObject
511
     * @param string $message
512
     * @param float $delta
513
     * @param int $maxDepth
514
     * @param bool $canonicalize
515
     * @param bool $ignoreCase
516
     */
517
    public function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) {
518
        $this->callAssertMethod(__FUNCTION__, [
519
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
520
        ]);
521
    }
522
523
    /**
524
     * Asserts that a variable is empty.
525
     *
526
     *
527
     * @throws AssertionFailedError
528
     */
529
    public function assertEmpty() {
530
        $this->callAssertMethod(__FUNCTION__);
531
    }
532
533
    /**
534
     * Asserts that a static attribute of a class or an attribute of an object
535
     * is empty.
536
     *
537
     * @param string $haystackAttributeName
538
     * @param string|object $haystackClassOrObject
539
     * @param string $message
540
     */
541
    public function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject) {
542
        $this->callAssertMethod(__FUNCTION__, [
543
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
544
        ]);
545
    }
546
547
    /**
548
     * Asserts that a variable is not empty.
549
     *
550
     * @param mixed $actual
551
     * @param string $message
552
     *
553
     * @throws AssertionFailedError
554
     */
555
    public function assertNotEmpty() {
556
        $this->callAssertMethod(__FUNCTION__, []);
557
    }
558
559
    /**
560
     * Asserts that a static attribute of a class or an attribute of an object
561
     * is not empty.
562
     *
563
     * @param string $haystackAttributeName
564
     * @param string|object $haystackClassOrObject
565
     * @param string $message
566
     */
567
    public function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject) {
568
        $this->callAssertMethod(__FUNCTION__, [
569
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
570
        ]);
571
    }
572
573
    /**
574
     * Asserts that a value is greater than another value.
575
     *
576
     * @param mixed $expected
577
     */
578
    public function assertGreaterThan($expected) {
579
        $this->callAssertMethod(__FUNCTION__, [
580
            'expected' => $expected,
581
        ]);
582
    }
583
584
    /**
585
     * Asserts that an attribute is greater than another value.
586
     *
587
     * @param mixed $expected
588
     * @param string $actualAttributeName
589
     * @param string|object $actualClassOrObject
590
     * @param string $message
591
     */
592
    public function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject) {
593
        $this->callAssertMethod(__FUNCTION__, [
594
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
595
        ]);
596
    }
597
598
    /**
599
     * Asserts that a value is greater than or equal to another value.
600
     *
601
     * @param mixed $expected
602
     */
603
    public function assertGreaterThanOrEqual($expected) {
604
        $this->callAssertMethod(__FUNCTION__, [
605
            'expected' => $expected,
606
        ]);
607
    }
608
609
    /**
610
     * Asserts that an attribute is greater than or equal to another value.
611
     *
612
     * @param mixed $expected
613
     * @param string $actualAttributeName
614
     * @param string|object $actualClassOrObject
615
     * @param string $message
616
     */
617
    public function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject) {
618
        $this->callAssertMethod(__FUNCTION__, [
619
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
620
        ]);
621
    }
622
623
    /**
624
     * Asserts that a value is smaller than another value.
625
     *
626
     * @param mixed $expected
627
     */
628
    public function assertLessThan($expected) {
629
        $this->callAssertMethod(__FUNCTION__, [
630
            'expected' => $expected,
631
        ]);
632
    }
633
634
    /**
635
     * Asserts that an attribute is smaller than another value.
636
     *
637
     * @param mixed $expected
638
     * @param string $actualAttributeName
639
     * @param string|object $actualClassOrObject
640
     * @param string $message
641
     */
642
    public function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject) {
643
        $this->callAssertMethod(__FUNCTION__, [
644
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
645
        ]);
646
    }
647
648
    /**
649
     * Asserts that a value is smaller than or equal to another value.
650
     *
651
     * @param mixed $expected
652
     */
653
    public function assertLessThanOrEqual($expected) {
654
        $this->callAssertMethod(__FUNCTION__, [
655
            'expected' => $expected,
656
        ]);
657
    }
658
659
    /**
660
     * Asserts that an attribute is smaller than or equal to another value.
661
     *
662
     * @param mixed $expected
663
     * @param string $actualAttributeName
664
     * @param string|object $actualClassOrObject
665
     * @param string $message
666
     */
667
    public function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject) {
668
        $this->callAssertMethod(__FUNCTION__, [
669
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
670
        ]);
671
    }
672
673
    /**
674
     * Asserts that the contents of one file is equal to the contents of another
675
     * file.
676
     *
677
     * @param string $expected
678
     * @param bool $canonicalize
679
     * @param bool $ignoreCase
680
     */
681
    public function assertFileEquals($expected, $canonicalize = false, $ignoreCase = false) {
682
        $this->callAssertMethod(__FUNCTION__, [
683
            'expected' => $expected,
684
            'additionalParams' => [
685
                $canonicalize,
686
                $ignoreCase,
687
            ],
688
        ]);
689
    }
690
691
    /**
692
     * Asserts that the contents of one file is not equal to the contents of
693
     * another file.
694
     *
695
     * @param string $expected
696
     * @param bool $canonicalize
697
     * @param bool $ignoreCase
698
     */
699
    public function assertFileNotEquals($expected, $canonicalize = false, $ignoreCase = false) {
700
        $this->callAssertMethod(__FUNCTION__, [
701
            'expected' => $expected,
702
            'additionalParams' => [
703
                $canonicalize,
704
                $ignoreCase,
705
            ],
706
        ]);
707
    }
708
709
    /**
710
     * Asserts that the contents of a string is equal
711
     * to the contents of a file.
712
     *
713
     * @param string $expectedFile
714
     * @param bool $canonicalize
715
     * @param bool $ignoreCase
716
     */
717
    public function assertStringEqualsFile($expectedFile, $canonicalize = false, $ignoreCase = false) {
718
        $this->callAssertMethod(__FUNCTION__, [
719
            'expected' => $expectedFile,
720
            'additionalParams' => [
721
                $canonicalize,
722
                $ignoreCase,
723
            ],
724
        ]);
725
    }
726
727
    /**
728
     * Asserts that the contents of a string is not equal
729
     * to the contents of a file.
730
     *
731
     * @param string $expectedFile
732
     * @param bool $canonicalize
733
     * @param bool $ignoreCase
734
     */
735
    public function assertStringNotEqualsFile($expectedFile, $canonicalize = false, $ignoreCase = false) {
736
        $this->callAssertMethod(__FUNCTION__, [
737
            'expected' => $expectedFile,
738
            'additionalParams' => [
739
                $canonicalize,
740
                $ignoreCase,
741
            ],
742
        ]);
743
    }
744
745
    /**
746
     * Asserts that a file/dir is readable.
747
     */
748
    public function assertIsReadable() {
749
        $this->callAssertMethod(__FUNCTION__);
750
    }
751
752
    /**
753
     * Asserts that a file/dir exists and is not readable.
754
     */
755
    public function assertNotIsReadable() {
756
        $this->callAssertMethod(__FUNCTION__);
757
    }
758
759
    /**
760
     * Asserts that a file/dir exists and is writable.
761
     */
762
    public function assertIsWritable() {
763
        $this->callAssertMethod(__FUNCTION__);
764
    }
765
766
    /**
767
     * Asserts that a file/dir exists and is not writable.
768
     */
769
    public function assertNotIsWritable() {
770
        $this->callAssertMethod(__FUNCTION__);
771
    }
772
773
    /**
774
     * Asserts that a directory exists.
775
     */
776
    public function assertDirectoryExists() {
777
        $this->callAssertMethod(__FUNCTION__);
778
    }
779
780
    /**
781
     * Asserts that a directory does not exist.
782
     */
783
    public function assertDirectoryNotExists() {
784
        $this->callAssertMethod(__FUNCTION__);
785
    }
786
787
    /**
788
     * Asserts that a directory exists and is readable.
789
     *
790
     * @param string $directory
791
     * @param string $message
792
     */
793
    public function assertDirectoryIsReadable($directory) {
794
        $this->callAssertMethod(__FUNCTION__, [
795
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
796
        ]);
797
    }
798
799
    /**
800
     * Asserts that a directory exists and is not readable.
801
     *
802
     * @param string $directory
803
     * @param string $message
804
     */
805
    public function assertDirectoryNotIsReadable($directory) {
806
        $this->callAssertMethod(__FUNCTION__, [
807
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
808
        ]);
809
    }
810
811
    /**
812
     * Asserts that a directory exists and is writable.
813
     *
814
     * @param string $directory
815
     * @param string $message
816
     */
817
    public function assertDirectoryIsWritable($directory) {
818
        $this->callAssertMethod(__FUNCTION__, [
819
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
820
        ]);
821
    }
822
823
    /**
824
     * Asserts that a directory exists and is not writable.
825
     *
826
     * @param string $directory
827
     * @param string $message
828
     */
829
    public function assertDirectoryNotIsWritable($directory) {
830
        $this->callAssertMethod(__FUNCTION__, [
831
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
832
        ]);
833
    }
834
835
    /**
836
     * Asserts that a file exists.
837
     */
838
    public function assertFileExists() {
839
        $this->callAssertMethod(__FUNCTION__);
840
    }
841
842
    /**
843
     * Asserts that a file does not exist.
844
     */
845
    public function assertFileNotExists() {
846
        $this->callAssertMethod(__FUNCTION__);
847
    }
848
849
    /**
850
     * Asserts that a file exists and is readable.
851
     *
852
     * @param string $file
853
     * @param string $message
854
     */
855
    public function assertFileIsReadable($file) {
856
        $this->callAssertMethod(__FUNCTION__, [
857
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
858
        ]);
859
    }
860
861
    /**
862
     * Asserts that a file exists and is not readable.
863
     *
864
     * @param string $file
865
     * @param string $message
866
     */
867
    public function assertFileNotIsReadable($file) {
868
        $this->callAssertMethod(__FUNCTION__, [
869
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
870
        ]);
871
    }
872
873
    /**
874
     * Asserts that a file exists and is writable.
875
     *
876
     * @param string $file
877
     * @param string $message
878
     */
879
    public function assertFileIsWritable($file) {
880
        $this->callAssertMethod(__FUNCTION__, [
881
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
882
        ]);
883
    }
884
885
    /**
886
     * Asserts that a file exists and is not writable.
887
     */
888
    public function assertFileNotIsWritable() {
889
        $this->callAssertMethod(__FUNCTION__);
890
    }
891
892
    /**
893
     * Asserts that a condition is true.
894
     *
895
     * @throws AssertionFailedError
896
     */
897
    public function assertTrue() {
898
        $this->callAssertMethod(__FUNCTION__);
899
    }
900
901
    /**
902
     * Asserts that a condition is not true.
903
     *
904
     * @throws AssertionFailedError
905
     */
906
    public function assertNotTrue() {
907
        $this->callAssertMethod(__FUNCTION__);
908
    }
909
910
    /**
911
     * Asserts that a condition is false.
912
     *
913
     * @throws AssertionFailedError
914
     */
915
    public function assertFalse() {
916
        $this->callAssertMethod(__FUNCTION__);
917
    }
918
919
    /**
920
     * Asserts that a condition is not false
921
     *
922
     * @throws AssertionFailedError
923
     */
924
    public function assertNotFalse() {
925
        $this->callAssertMethod(__FUNCTION__);
926
    }
927
928
    /**
929
     * Asserts that a variable is null.
930
     *
931
     * @param mixed $actual
932
     */
933
    public function assertNull() {
934
        $this->callAssertMethod(__FUNCTION__);
935
    }
936
937
    /**
938
     * Asserts that a variable is not null.
939
     */
940
    public function assertNotNull() {
941
        $this->callAssertMethod(__FUNCTION__);
942
    }
943
944
    /**
945
     * Asserts that a variable is finite.
946
     */
947
    public function assertFinite() {
948
        $this->callAssertMethod(__FUNCTION__);
949
    }
950
951
    /**
952
     * Asserts that a variable is infinite.
953
     */
954
    public function assertInfinite() {
955
        $this->callAssertMethod(__FUNCTION__);
956
    }
957
958
    /**
959
     * Asserts that a variable is nan.
960
     */
961
    public function assertNan() {
962
        $this->callAssertMethod(__FUNCTION__);
963
    }
964
965
    /**
966
     * Asserts that a class exists
967
     */
968
    public function assertClassExists() {
969
        $this->callAssertMethod('classExists');
970
    }
971
972
    protected function classExists($class, $message) {
973
        $this->test->assertTrue(class_exists($class), $message);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not exist on PHPUnit\Framework\Test. It seems like you code against a sub-type of PHPUnit\Framework\Test such as PHPUnit\Framework\TestCase. ( Ignorable by Annotation )

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

973
        $this->test->/** @scrutinizer ignore-call */ 
974
                     assertTrue(class_exists($class), $message);
Loading history...
974
    }
975
976
    /**
977
     * Asserts that a class does not exist
978
     */
979
    public function assertClassDoesNotExist() {
980
        $this->callAssertMethod('classDoesNotExist');
981
    }
982
983
    protected function classDoesNotExist($class, $message) {
984
        $this->test->assertFalse(class_exists($class), $message);
0 ignored issues
show
Bug introduced by
The method assertFalse() does not exist on PHPUnit\Framework\Test. It seems like you code against a sub-type of PHPUnit\Framework\Test such as PHPUnit\Framework\TestCase. ( Ignorable by Annotation )

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

984
        $this->test->/** @scrutinizer ignore-call */ 
985
                     assertFalse(class_exists($class), $message);
Loading history...
985
    }
986
987
    /**
988
     * Asserts that a class does not exist
989
     */
990
    public function assertClassIsInterface() {
991
        $this->callAssertMethod('classIsInterface');
992
    }
993
994
    protected function classIsInterface($class, $message) {
995
        $this->test->assertTrue(interface_exists($class), $message);
996
    }
997
998
    /**
999
     * Asserts that a class does not exist
1000
     */
1001
    public function assertClassIsNotInterface() {
1002
        $this->callAssertMethod('classIsNotInterface');
1003
    }
1004
1005
    protected function classIsNotInterface($class, $message) {
1006
        $this->test->assertFalse(interface_exists($class), $message);
1007
    }
1008
1009
    /**
1010
     * Asserts that a class has a specified attribute.
1011
     *
1012
     * @param string $attributeName
1013
     */
1014
    public function assertClassHasAttribute($attributeName) {
1015
        $this->callAssertMethod(__FUNCTION__, [
1016
            'expected' => $attributeName,
1017
        ]);
1018
    }
1019
1020
    /**
1021
     * Asserts that a class does not have a specified attribute.
1022
     *
1023
     * @param string $attributeName
1024
     */
1025
    public function assertClassNotHasAttribute($attributeName) {
1026
        $this->callAssertMethod(__FUNCTION__, [
1027
            'expected' => $attributeName,
1028
        ]);
1029
    }
1030
1031
    /**
1032
     * Asserts that a class has a specified static attribute.
1033
     *
1034
     * @param string $attributeName
1035
     */
1036
    public function assertClassHasStaticAttribute($attributeName) {
1037
        $this->callAssertMethod(__FUNCTION__, [
1038
            'expected' => $attributeName,
1039
        ]);
1040
    }
1041
1042
    /**
1043
     * Asserts that a class does not have a specified static attribute.
1044
     *
1045
     * @param string $attributeName
1046
     */
1047
    public function assertClassNotHasStaticAttribute($attributeName) {
1048
        $this->callAssertMethod(__FUNCTION__, [
1049
            'expected' => $attributeName,
1050
        ]);
1051
    }
1052
1053
    /**
1054
     * Asserts that an object has a specified attribute.
1055
     *
1056
     * @param string $attributeName
1057
     */
1058
    public function assertObjectHasAttribute($attributeName) {
1059
        $this->callAssertMethod(__FUNCTION__, [
1060
            'expected' => $attributeName,
1061
        ]);
1062
    }
1063
1064
    /**
1065
     * Asserts that an object does not have a specified attribute.
1066
     *
1067
     * @param string $attributeName
1068
     */
1069
    public function assertObjectNotHasAttribute($attributeName) {
1070
        $this->callAssertMethod(__FUNCTION__, [
1071
            'expected' => $attributeName,
1072
        ]);
1073
    }
1074
1075
    /**
1076
     * Asserts that two variables have the same type and value.
1077
     * Used on objects, it asserts that two variables reference
1078
     * the same object.
1079
     *
1080
     * @param mixed $expected
1081
     */
1082
    public function assertSame($expected) {
1083
        $this->callAssertMethod(__FUNCTION__, [
1084
            'expected' => $expected,
1085
        ]);
1086
    }
1087
1088
    /**
1089
     * Asserts that a variable and an attribute of an object have the same type
1090
     * and value.
1091
     *
1092
     * @param mixed $expected
1093
     * @param string $actualAttributeName
1094
     * @param string|object $actualClassOrObject
1095
     * @param string $message
1096
     */
1097
    public function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject) {
1098
        $this->callAssertMethod(__FUNCTION__, [
1099
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
1100
        ]);
1101
    }
1102
1103
    /**
1104
     * Asserts that two variables do not have the same type and value.
1105
     * Used on objects, it asserts that two variables do not reference
1106
     * the same object.
1107
     *
1108
     * @param mixed $expected
1109
     */
1110
    public function assertNotSame($expected) {
1111
        $this->callAssertMethod(__FUNCTION__, [
1112
            'expected' => $expected,
1113
        ]);
1114
    }
1115
1116
    /**
1117
     * Asserts that a variable and an attribute of an object do not have the
1118
     * same type and value.
1119
     *
1120
     * @param mixed $expected
1121
     * @param string $actualAttributeName
1122
     * @param string|object $actualClassOrObject
1123
     * @param string $message
1124
     */
1125
    public function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject) {
1126
        $this->callAssertMethod(__FUNCTION__, [
1127
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
1128
        ]);
1129
    }
1130
1131
    /**
1132
     * Asserts that a variable is of a given type.
1133
     *
1134
     * @param string $expected
1135
     */
1136
    public function assertInstanceOf($expected) {
1137
        $this->callAssertMethod(__FUNCTION__, [
1138
            'expected' => $expected,
1139
        ]);
1140
    }
1141
1142
    /**
1143
     * Asserts that an attribute is of a given type.
1144
     *
1145
     * @param string $expected
1146
     * @param string $attributeName
1147
     * @param string|object $classOrObject
1148
     * @param string $message
1149
     */
1150
    public function assertAttributeInstanceOf($expected, $attributeName, $classOrObject) {
1151
        $this->callAssertMethod(__FUNCTION__, [
1152
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
1153
        ]);
1154
    }
1155
1156
    /**
1157
     * Asserts that a variable is not of a given type.
1158
     *
1159
     * @param string $expected
1160
     */
1161
    public function assertNotInstanceOf($expected) {
1162
        $this->callAssertMethod(__FUNCTION__, [
1163
            'expected' => $expected,
1164
        ]);
1165
    }
1166
1167
    /**
1168
     * Asserts that an attribute is of a given type.
1169
     *
1170
     * @param string $expected
1171
     * @param string $attributeName
1172
     * @param string|object $classOrObject
1173
     * @param string $message
1174
     */
1175
    public function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject) {
1176
        $this->callAssertMethod(__FUNCTION__, [
1177
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
1178
        ]);
1179
    }
1180
1181
    /**
1182
     * Asserts that a variable is of a given type.
1183
     *
1184
     * @param string $expected
1185
     */
1186
    public function assertInternalType($expected) {
1187
        $this->callAssertMethod(__FUNCTION__, [
1188
            'expected' => $expected,
1189
        ]);
1190
    }
1191
1192
    /**
1193
     * Asserts that an attribute is of a given type.
1194
     *
1195
     * @param string $expected
1196
     * @param string $attributeName
1197
     * @param string|object $classOrObject
1198
     * @param string $message
1199
     */
1200
    public function assertAttributeInternalType($expected, $attributeName, $classOrObject) {
1201
        $this->callAssertMethod(__FUNCTION__, [
1202
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
1203
        ]);
1204
    }
1205
1206
    /**
1207
     * Asserts that a variable is not of a given type.
1208
     *
1209
     * @param string $expected
1210
     */
1211
    public function assertNotInternalType($expected) {
1212
        $this->callAssertMethod(__FUNCTION__, [
1213
            'expected' => $expected,
1214
        ]);
1215
    }
1216
1217
    /**
1218
     * Asserts that an attribute is of a given type.
1219
     *
1220
     * @param string $expected
1221
     * @param string $attributeName
1222
     * @param string|object $classOrObject
1223
     * @param string $message
1224
     */
1225
    public function assertAttributeNotInternalType($expected, $attributeName, $classOrObject) {
1226
        $this->callAssertMethod(__FUNCTION__, [
1227
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
1228
        ]);
1229
    }
1230
1231
    /**
1232
     * Asserts that a string matches a given regular expression.
1233
     *
1234
     * @param string $pattern
1235
     */
1236
    public function assertRegExp($pattern) {
1237
        $this->callAssertMethod(__FUNCTION__, [
1238
            'expected' => $pattern,
1239
        ]);
1240
    }
1241
1242
    /**
1243
     * Asserts that a string does not match a given regular expression.
1244
     *
1245
     * @param string $pattern
1246
     */
1247
    public function assertNotRegExp($pattern, $string) {
1248
        $this->callAssertMethod(__FUNCTION__, [
1249
            'expected' => $key,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $key seems to be never defined.
Loading history...
1250
        ]);
1251
    }
1252
1253
    /**
1254
     * Assert that the size of two arrays (or `\Countable` or `\Traversable` objects)
1255
     * is the same.
1256
     *
1257
     * @param array|\Countable|\Traversable $expected
1258
     */
1259
    public function assertSameSize($expected) {
1260
        $this->callAssertMethod(__FUNCTION__, [
1261
            'expected' => $expected,
1262
        ]);
1263
    }
1264
1265
    /**
1266
     * Assert that the size of two arrays (or `\Countable` or `\Traversable` objects)
1267
     * is not the same.
1268
     *
1269
     * @param array|\Countable|\Traversable $expected
1270
     * @param array|\Countable|\Traversable $actual
1271
     * @param string $message
1272
     */
1273
    public function assertNotSameSize($expected) {
1274
        $this->callAssertMethod(__FUNCTION__, [
1275
            'expected' => $expected,
1276
        ]);
1277
    }
1278
1279
    /**
1280
     * Asserts that a string matches a given format string.
1281
     *
1282
     * @param string $format
1283
     */
1284
    public function assertStringMatchesFormat($format) {
1285
        $this->callAssertMethod(__FUNCTION__, [
1286
            'expected' => $format,
1287
        ]);
1288
    }
1289
1290
    /**
1291
     * Asserts that a string does not match a given format string.
1292
     *
1293
     * @param string $format
1294
     */
1295
    public function assertStringNotMatchesFormat($format) {
1296
        $this->callAssertMethod(__FUNCTION__, [
1297
            'expected' => $format,
1298
        ]);
1299
    }
1300
1301
    /**
1302
     * Asserts that a string matches a given format file.
1303
     *
1304
     * @param string $formatFile
1305
     */
1306
    public function assertStringMatchesFormatFile($formatFile) {
1307
        $this->callAssertMethod(__FUNCTION__, [
1308
            'expected' => $formatFile,
1309
        ]);
1310
    }
1311
1312
    /**
1313
     * Asserts that a string does not match a given format string.
1314
     *
1315
     * @param string $formatFile
1316
     */
1317
    public function assertStringNotMatchesFormatFile($formatFile) {
1318
        $this->callAssertMethod(__FUNCTION__, [
1319
            'expected' => $formatFile,
1320
        ]);
1321
    }
1322
1323
    /**
1324
     * Asserts that a string starts with a given prefix.
1325
     *
1326
     * @param string $prefix
1327
     */
1328
    public function assertStringStartsWith($prefix) {
1329
        $this->callAssertMethod(__FUNCTION__, [
1330
            'expected' => $prefix,
1331
        ]);
1332
    }
1333
1334
    /**
1335
     * Asserts that a string starts not with a given prefix.
1336
     *
1337
     * @param string $prefix
1338
     */
1339
    public function assertStringStartsNotWith($prefix) {
1340
        $this->callAssertMethod(__FUNCTION__, [
1341
            'expected' => $prefix,
1342
        ]);
1343
    }
1344
1345
    /**
1346
     * Asserts that a string ends with a given suffix.
1347
     *
1348
     * @param string $suffix
1349
     */
1350
    public function assertStringEndsWith($suffix) {
1351
        $this->callAssertMethod(__FUNCTION__, [
1352
            'expected' => $suffix,
1353
        ]);
1354
    }
1355
1356
    /**
1357
     * Asserts that a string ends not with a given suffix.
1358
     *
1359
     * @param string $suffix
1360
     * @param string $string
1361
     * @param string $message
1362
     */
1363
    public function assertStringEndsNotWith($suffix) {
1364
        $this->callAssertMethod(__FUNCTION__, [
1365
            'expected' => $suffix,
1366
        ]);
1367
    }
1368
1369
    /**
1370
     * Asserts that two XML files are equal.
1371
     *
1372
     * @param string $expectedFile
1373
     */
1374
    public function assertXmlFileEqualsXmlFile($expectedFile) {
1375
        $this->callAssertMethod(__FUNCTION__, [
1376
            'expected' => $expectedFile,
1377
        ]);
1378
    }
1379
1380
    /**
1381
     * Asserts that two XML files are not equal.
1382
     *
1383
     * @param string $expectedFile
1384
     * @param string $actualFile
1385
     * @param string $message
1386
     */
1387
    public function assertXmlFileNotEqualsXmlFile($expectedFile) {
1388
        $this->callAssertMethod(__FUNCTION__, [
1389
            'expected' => $expectedFile,
1390
        ]);
1391
    }
1392
1393
    /**
1394
     * Asserts that two XML documents are equal.
1395
     *
1396
     * @param string $expectedFile
1397
     */
1398
    public function assertXmlStringEqualsXmlFile($expectedFile) {
1399
        $this->callAssertMethod(__FUNCTION__, [
1400
            'expected' => $expectedFile,
1401
        ]);
1402
    }
1403
1404
    /**
1405
     * Asserts that two XML documents are not equal.
1406
     *
1407
     * @param string $expectedFile
1408
     */
1409
    public function assertXmlStringNotEqualsXmlFile($expectedFile) {
1410
        $this->callAssertMethod(__FUNCTION__, [
1411
            'expected' => $expectedFile,
1412
        ]);
1413
    }
1414
1415
    /**
1416
     * Asserts that two XML documents are equal.
1417
     *
1418
     * @param string|\DOMDocument $expectedXml
1419
     * @param string $message
1420
     */
1421
    public function assertXmlStringEqualsXmlString($expectedXml) {
1422
        $this->callAssertMethod(__FUNCTION__, [
1423
            'expected' => $expectedXml,
1424
        ]);
1425
    }
1426
1427
    /**
1428
     * Asserts that two XML documents are not equal.
1429
     *
1430
     * @param string|\DOMDocument $expectedXml
1431
     */
1432
    public function assertXmlStringNotEqualsXmlString($expectedXml) {
1433
        $this->callAssertMethod(__FUNCTION__, [
1434
            'expected' => $expectedXml,
1435
        ]);
1436
    }
1437
1438
    /**
1439
     * Asserts that a hierarchy of DOMElements matches.
1440
     *
1441
     * @param \DOMElement $expectedElement
1442
     * @param bool $checkAttributes
1443
     */
1444
    public function assertEqualXMLStructure(\DOMElement $expectedElement, $checkAttributes = false) {
1445
        $this->callAssertMethod(__FUNCTION__, [
1446
            'expected' => $expectedElement,
1447
            'options' => [
1448
                $checkAttributes,
1449
            ],
1450
        ]);
1451
    }
1452
1453
    /**
1454
     * Asserts that a string is a valid JSON string.
1455
     */
1456
    public function assertJson() {
1457
        $this->callAssertMethod(__FUNCTION__);
1458
    }
1459
1460
    /**
1461
     * Asserts that two given JSON encoded objects or arrays are equal.
1462
     *
1463
     * @param string $expectedJson
1464
     */
1465
    public function assertJsonStringEqualsJsonString($expectedJson) {
1466
        $this->callAssertMethod(__FUNCTION__, [
1467
            'expected' => $expectedJson,
1468
        ]);
1469
    }
1470
1471
    /**
1472
     * Asserts that two given JSON encoded objects or arrays are not equal.
1473
     *
1474
     * @param string $expectedJson
1475
     */
1476
    public function assertJsonStringNotEqualsJsonString($expectedJson) {
1477
        $this->callAssertMethod(__FUNCTION__, [
1478
            'expected' => $expectedJson,
1479
        ]);
1480
    }
1481
1482
    /**
1483
     * Asserts that the generated JSON encoded object and the content of the given file are equal.
1484
     *
1485
     * @param string $expectedFile
1486
     */
1487
    public function assertJsonStringEqualsJsonFile($expectedFile) {
1488
        $this->callAssertMethod(__FUNCTION__, [
1489
            'expected' => $expectedFile,
1490
        ]);
1491
    }
1492
1493
    /**
1494
     * Asserts that the generated JSON encoded object and the content of the given file are not equal.
1495
     *
1496
     * @param string $expectedFile
1497
     */
1498
    public function assertJsonStringNotEqualsJsonFile($expectedFile) {
1499
        $this->callAssertMethod(__FUNCTION__, [
1500
            'expected' => $expectedFile,
1501
        ]);
1502
    }
1503
1504
    /**
1505
     * Asserts that two JSON files are equal.
1506
     *
1507
     * @param string $expectedFile
1508
     */
1509
    public function assertJsonFileEqualsJsonFile($expectedFile) {
1510
        $this->callAssertMethod(__FUNCTION__, [
1511
            'expected' => $expectedFile,
1512
        ]);
1513
    }
1514
1515
    /**
1516
     * Asserts that two JSON files are not equal.
1517
     *
1518
     * @param string $expectedFile
1519
     */
1520
    public function assertJsonFileNotEqualsJsonFile($expectedFile) {
1521
        $this->callAssertMethod(__FUNCTION__, [
1522
            'expected' => $expectedFile,
1523
        ]);
1524
    }
1525
}