Completed
Push — master ( 7cb054...584ba8 )
by Tim
44:11 queued 26:38
created

Assert   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 71
rs 10
wmc 5
lcom 0
cbo 2
1
<?php
2
/*
3
 * Copyright (c) Ouzo contributors, http://ouzoframework.org
4
 * This file is made available under the MIT License (view the LICENSE file for more information).
5
 */
6
namespace Ouzo\Tests;
7
8
use Ouzo\Model;
9
10
/**
11
 * Class Assert
12
 * @package Ouzo\Tests
13
 */
14
class Assert
15
{
16
    /**
17
     * Fluent custom array assertion to simplify your tests.
18
     *
19
     * Sample usage:
20
     * <code>
21
     *  $animals = array('cat', 'dog', 'pig');
22
     *  Assert::thatArray($animals)->hasSize(3)->contains('cat');
23
     *  Assert::thatArray($animals)->containsOnly('pig', 'dog', 'cat');
24
     *  Assert::thatArray($animals)->containsExactly('cat', 'dog', 'pig');
25
     *  Assert::thatArray(array('id' => 123, 'name' => 'john'))->containsKeyAndValue(array('id' => 123));
26
     * </code>
27
     *
28
     * @param array $actual
29
     * @return ArrayAssert
30
     */
31
    public static function thatArray(array $actual)
32
    {
33
        return ArrayAssert::that($actual);
34
    }
35
36
    /**
37
     * Fluent custom model assertion to simplify your tests.
38
     *
39
     * Sample usage:
40
     * <code>
41
     *  Assert::thatModel(new User(['name' => 'bob']))->hasSameAttributesAs(new User(['name' => 'bob']));
42
     * </code>
43
     *
44
     * @param Model $actual
45
     * @return ModelAssert
46
     */
47
    public static function thatModel(Model $actual)
48
    {
49
        return ModelAssert::that($actual);
50
    }
51
52
    /**
53
     * Fluent custom session assertion to simplify your tests.
54
     *
55
     * Sample usage:
56
     * <code>
57
     *  Session::push('key1', 'key2', 'value1');
58
     *  Assert::thatSession()->hasSize(1)->contains('value1');
59
     * </code>
60
     *
61
     * Class Assert
62
     * @package Ouzo\Tests
63
     */
64
    public static function thatSession()
65
    {
66
        return ArrayAssert::that(isset($_SESSION) ? $_SESSION : array());
67
    }
68
69
    /**
70
     * Fluent custom string assertion to simplify your tests.
71
     *
72
     * Sample usage:
73
     * <code>
74
     *  Assert::thatString("Frodo")->startsWith("Fro")->endsWith("do")->contains("rod")->doesNotContain("fro")->hasSize(5)->matches('/Fro\w+/');
75
     * </code>
76
     *
77
     * @param $string
78
     * @return StringAssert
79
     */
80
    public static function thatString($string)
81
    {
82
        return StringAssert::that($string);
83
    }
84
}
85