1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace tests\Happyr\DoctrineSpecification; |
4
|
|
|
|
5
|
|
|
use Happyr\DoctrineSpecification\Filter\MemberOfX; |
6
|
|
|
use Happyr\DoctrineSpecification\Logic\LogicX; |
7
|
|
|
use Happyr\DoctrineSpecification\Operand\Addition; |
8
|
|
|
use Happyr\DoctrineSpecification\Operand\Alias; |
9
|
|
|
use Happyr\DoctrineSpecification\Operand\BitAnd; |
10
|
|
|
use Happyr\DoctrineSpecification\Operand\BitLeftShift; |
11
|
|
|
use Happyr\DoctrineSpecification\Operand\BitNot; |
12
|
|
|
use Happyr\DoctrineSpecification\Operand\BitOr; |
13
|
|
|
use Happyr\DoctrineSpecification\Operand\BitRightShift; |
14
|
|
|
use Happyr\DoctrineSpecification\Operand\BitXor; |
15
|
|
|
use Happyr\DoctrineSpecification\Operand\Division; |
16
|
|
|
use Happyr\DoctrineSpecification\Operand\Modulo; |
17
|
|
|
use Happyr\DoctrineSpecification\Operand\Multiplication; |
18
|
|
|
use Happyr\DoctrineSpecification\Operand\PlatformFunction; |
19
|
|
|
use Happyr\DoctrineSpecification\Operand\Subtraction; |
20
|
|
|
use Happyr\DoctrineSpecification\Query\AddSelect; |
21
|
|
|
use Happyr\DoctrineSpecification\Query\Select; |
22
|
|
|
use Happyr\DoctrineSpecification\Query\Selection\SelectAs; |
23
|
|
|
use Happyr\DoctrineSpecification\Query\Selection\SelectEntity; |
24
|
|
|
use Happyr\DoctrineSpecification\Query\Selection\SelectHiddenAs; |
25
|
|
|
use Happyr\DoctrineSpecification\Spec; |
26
|
|
|
use PhpSpec\ObjectBehavior; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @mixin Spec |
30
|
|
|
*/ |
31
|
|
|
class SpecSpec extends ObjectBehavior |
32
|
|
|
{ |
33
|
|
|
public function it_creates_an_x_specification() |
34
|
|
|
{ |
35
|
|
|
$this->andX()->shouldReturnAnInstanceOf(LogicX::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function it_creates_add_operand() |
39
|
|
|
{ |
40
|
|
|
$this->add('foo', 'bar')->shouldReturnAnInstanceOf(Addition::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function it_creates_sub_operand() |
44
|
|
|
{ |
45
|
|
|
$this->sub('foo', 'bar')->shouldReturnAnInstanceOf(Subtraction::class); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function it_creates_mul_operand() |
49
|
|
|
{ |
50
|
|
|
$this->mul('foo', 'bar')->shouldReturnAnInstanceOf(Multiplication::class); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function it_creates_div_operand() |
54
|
|
|
{ |
55
|
|
|
$this->div('foo', 'bar')->shouldReturnAnInstanceOf(Division::class); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function it_creates_mod_operand() |
59
|
|
|
{ |
60
|
|
|
$this->mod('foo', 'bar')->shouldReturnAnInstanceOf(Modulo::class); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function it_create_bit_and_operand() |
64
|
|
|
{ |
65
|
|
|
$this->bAnd('foo', 'bar')->shouldReturnAnInstanceOf(BitAnd::class); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function it_create_bit_or_operand() |
69
|
|
|
{ |
70
|
|
|
$this->bOr('foo', 'bar')->shouldReturnAnInstanceOf(BitOr::class); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function it_create_bit_xor_operand() |
74
|
|
|
{ |
75
|
|
|
$this->bXor('foo', 'bar')->shouldReturnAnInstanceOf(BitXor::class); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function it_create_bit_left_shift_operand() |
79
|
|
|
{ |
80
|
|
|
$this->bLs('foo', 'bar')->shouldReturnAnInstanceOf(BitLeftShift::class); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function it_create_bit_right_shift_operand() |
84
|
|
|
{ |
85
|
|
|
$this->bRs('foo', 'bar')->shouldReturnAnInstanceOf(BitRightShift::class); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function it_create_bit_not_operand() |
89
|
|
|
{ |
90
|
|
|
$this->bNot('foo')->shouldReturnAnInstanceOf(BitNot::class); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function it_creates_an_function() |
94
|
|
|
{ |
95
|
|
|
$this->fun('UPPER', 'arg')->shouldReturnAnInstanceOf(PlatformFunction::class); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function it_creates_an_function_with_many_args() |
99
|
|
|
{ |
100
|
|
|
$this->fun('CONCAT', 'a', 'b')->shouldReturnAnInstanceOf(PlatformFunction::class); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function it_creates_an_function_with_many_args_as_array() |
104
|
|
|
{ |
105
|
|
|
$this->fun('CONCAT', ['a', 'b'])->shouldReturnAnInstanceOf(PlatformFunction::class); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function it_creates_an_magic_function() |
109
|
|
|
{ |
110
|
|
|
$this->__callStatic('UPPER', ['arg'])->shouldReturnAnInstanceOf(PlatformFunction::class); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function it_creates_an_magic_function_many_args() |
114
|
|
|
{ |
115
|
|
|
$this->__callStatic('CONCAT', ['a', 'b'])->shouldReturnAnInstanceOf(PlatformFunction::class); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function it_creates_an_magic_function_many_args_inner() |
119
|
|
|
{ |
120
|
|
|
$this->__callStatic('CONCAT', [['a', 'b']])->shouldReturnAnInstanceOf(PlatformFunction::class); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function it_creates_select_query_modifier() |
124
|
|
|
{ |
125
|
|
|
$this->select('foo')->shouldReturnAnInstanceOf(Select::class); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function it_creates_add_select_query_modifier() |
129
|
|
|
{ |
130
|
|
|
$this->addSelect('foo')->shouldReturnAnInstanceOf(AddSelect::class); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function it_creates_select_entity_selection() |
134
|
|
|
{ |
135
|
|
|
$this->selectEntity('u')->shouldReturnAnInstanceOf(SelectEntity::class); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function it_creates_select_as_selection() |
139
|
|
|
{ |
140
|
|
|
$this->selectAs('foo', 'bar')->shouldReturnAnInstanceOf(SelectAs::class); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function it_creates_select_hidden_as_selection() |
144
|
|
|
{ |
145
|
|
|
$this->selectHiddenAs('foo', 'bar')->shouldReturnAnInstanceOf(SelectHiddenAs::class); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function it_creates_alias_operand() |
149
|
|
|
{ |
150
|
|
|
$this->alias('foo')->shouldReturnAnInstanceOf(Alias::class); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function it_creates_member_of_filter() |
154
|
|
|
{ |
155
|
|
|
$this->memberOfX('foo')->shouldReturnAnInstanceOf(MemberOfX::class); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|