JoinTraitTest   A
last analyzed

Complexity

Total Complexity 26

Size/Duplication

Total Lines 681
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 356
c 2
b 0
f 0
dl 0
loc 681
rs 10
wmc 26

47 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ testFullOuterJoinAs() 0 31 1
testBuildJoinQueryPart() 0 7 ?
testBuildJoinQueryPartWhenEmpty() 0 5 ?
A hp$0 ➔ testInnerJoin() 0 20 1
A hp$0 ➔ testCrossJoin() 0 20 1
A hp$0 ➔ testJoin() 0 20 1
A hp$0 ➔ testJoinWithEmptyTable() 0 10 1
A hp$0 ➔ testJoinWithInvalidJoin() 0 10 1
A hp$0 ➔ buildJoinQueryPartPublic() 0 3 1
A hp$0 ➔ testJoinWithSameJoin() 0 12 1
A hp$0 ➔ testFullOuterJoin() 0 24 1
A hp$0 ➔ testBuildJoinQueryPartWhenEmpty() 0 5 1
A hp$0 ➔ testRightJoin() 0 20 1
A hp$0 ➔ testRightJoinAs() 0 31 1
A hp$0 ➔ __construct() 0 4 1
A hp$0 ➔ testJoinWithEmptyOnCondition() 0 10 1
B hp$0 ➔ joinAsData() 0 81 1
A hp$0 ➔ testInnerJoinAs() 0 31 1
A hp$0 ➔ setUp() 0 36 1
A hp$0 ➔ testCrossJoinAs() 0 31 1
A hp$0 ➔ testJoinAs() 0 20 1
A hp$0 ➔ joinData() 0 3 1
A hp$0 ➔ testJoinAsWithEmptyAlias() 0 11 1
A hp$0 ➔ testBuildJoinQueryPart() 0 7 1
A hp$0 ➔ testLeftJoin() 0 20 1
A hp$0 ➔ testLeftJoinAs() 0 31 1
A hp$0 ➔ clearJoinData() 0 3 1
testLeftJoinAs() 0 31 ?
testFullOuterJoin() 0 24 ?
testJoinWithInvalidJoin() 0 10 ?
joinAsData() 0 81 ?
testLeftJoin() 0 20 ?
testInnerJoinAs() 0 31 ?
testInnerJoin() 0 20 ?
testCrossJoin() 0 20 ?
joinData() 0 71 ?
testRightJoinAs() 0 31 ?
testJoinAsWithEmptyAlias() 0 11 ?
testJoinWithEmptyOnCondition() 0 10 ?
setUp() 0 36 ?
testJoinAs() 0 20 ?
testCrossJoinAs() 0 31 ?
testJoin() 0 20 ?
testJoinWithSameJoin() 0 12 ?
testRightJoin() 0 20 ?
testJoinWithEmptyTable() 0 10 ?
testFullOuterJoinAs() 0 31 ?
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Tests\Unit\Dms\MySQL\QueryBuilder\Traits;
4
5
use Janisbiz\LightOrm\Dms\MySQL\Enum\JoinEnum;
6
use Janisbiz\LightOrm\Dms\MySQL\QueryBuilder\QueryBuilderException;
7
use Janisbiz\LightOrm\Dms\MySQL\QueryBuilder\Traits\BindTrait;
8
use Janisbiz\LightOrm\Dms\MySQL\QueryBuilder\Traits\JoinTrait;
9
10
class JoinTraitTest extends AbstractTraitTestCase
11
{
12
    const JOIN_INVALID_JOIN = 'INVALID';
13
14
    const JOIN_EMPTY_TABLE = '';
15
    const JOIN_EMPTY_ON_CONDITION = '';
16
    const JOIN_EMPTY_ALIAS = '';
17
18
    const JOIN_DEFAULT_JOIN = JoinEnum::INNER_JOIN;
19
    const JOIN_DEFAULT_TABLE = 'table1';
20
    const JOIN_DEFAULT_ON_CONDITION = 'table1.column1 = table2.column2 AND table1.column2 = :column2_ValueBind';
21
    const JOIN_DEFAULT = [
22
        self::JOIN_DEFAULT_JOIN . ' ' . self::JOIN_DEFAULT_TABLE . ' ON (' . self::JOIN_DEFAULT_ON_CONDITION . ')',
23
    ];
24
    const JOIN_BIND_DEFAULT = [
25
        'column2_ValueBind' => 'column2_value',
26
    ];
27
28
    const JOIN_TABLE = 'table0';
29
    const JOIN_TABLE_ALIAS = 'table0_alias';
30
    const JOIN_ON_CONDITION = 'table0.column0 = table1.column1 AND table1.column3 = :column3_ValueBind';
31
    const JOIN_BIND = [
32
        'column3_ValueBind' => 'column3_value',
33
    ];
34
35
    /**
36
     * @var JoinTrait|BindTrait
37
     */
38
    private $joinTraitClass;
39
40
    public function setUp()
41
    {
42
        $this->joinTraitClass = new class (JoinTraitTest::JOIN_BIND_DEFAULT, JoinTraitTest::JOIN_DEFAULT)
43
        {
44
            use BindTrait;
45
            use JoinTrait;
46
47
            /**
48
             * @param array $bindDataDefault
49
             * @param array $joinDataDefault
50
             */
51
            public function __construct(array $bindDataDefault, array $joinDataDefault)
52
            {
53
                $this->bind = $bindDataDefault;
54
                $this->join = $joinDataDefault;
55
            }
56
57
            /**
58
             * @return array
59
             */
60
            public function joinData(): array
61
            {
62
                return $this->join;
63
            }
64
65
            public function clearJoinData()
66
            {
67
                $this->join = [];
68
            }
69
70
            /**
71
             * @return null|string
72
             */
73
            public function buildJoinQueryPartPublic(): ?string
74
            {
75
                return $this->buildJoinQueryPart();
76
            }
77
        };
78
    }
79
80
    /**
81
     * @dataProvider joinData
82
     *
83
     * @param string $join
84
     * @param string $tableName
85
     * @param string $onCondition
86
     * @param array $bind
87
     */
88
    public function testJoin($join, $tableName, $onCondition, array $bind)
89
    {
90
        $object = $this->joinTraitClass->join($join, $tableName, $onCondition, $bind);
0 ignored issues
show
Bug introduced by
It seems like join() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

90
        /** @scrutinizer ignore-call */ 
91
        $object = $this->joinTraitClass->join($join, $tableName, $onCondition, $bind);
Loading history...
91
        $this->assertObjectUsesTrait(BindTrait::class, $object);
92
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
93
        $this->assertEquals(
94
            \array_merge(
95
                static::JOIN_DEFAULT,
96
                [
97
                    \sprintf('%s %s ON (%s)', $join, $tableName, $onCondition),
98
                ]
99
            ),
100
            $this->joinTraitClass->joinData()
0 ignored issues
show
Bug introduced by
It seems like joinData() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

100
            $this->joinTraitClass->/** @scrutinizer ignore-call */ 
101
                                   joinData()
Loading history...
101
        );
102
        $this->assertEquals(
103
            \array_merge(
104
                static::JOIN_BIND_DEFAULT,
105
                $bind
106
            ),
107
            $this->joinTraitClass->bindData()
0 ignored issues
show
Bug introduced by
It seems like bindData() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

107
            $this->joinTraitClass->/** @scrutinizer ignore-call */ 
108
                                   bindData()
Loading history...
108
        );
109
    }
110
111
    /**
112
     * @dataProvider joinData
113
     *
114
     * @param string $join
115
     * @param string $tableName
116
     * @param string $onCondition
117
     * @param array $bind
118
     */
119
    public function testBuildJoinQueryPart($join, $tableName, $onCondition, array $bind)
120
    {
121
        $this->joinTraitClass->join($join, $tableName, $onCondition, $bind);
122
123
        $this->assertEquals(
124
            \implode(' ', $this->joinTraitClass->joinData()),
125
            $this->joinTraitClass->buildJoinQueryPartPublic()
0 ignored issues
show
Bug introduced by
It seems like buildJoinQueryPartPublic() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

125
            $this->joinTraitClass->/** @scrutinizer ignore-call */ 
126
                                   buildJoinQueryPartPublic()
Loading history...
Bug introduced by
The method buildJoinQueryPartPublic() does not exist on Janisbiz\LightOrm\Dms\My...uilder\Traits\JoinTrait. Did you maybe mean buildJoinQueryPart()? ( Ignorable by Annotation )

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

125
            $this->joinTraitClass->/** @scrutinizer ignore-call */ 
126
                                   buildJoinQueryPartPublic()

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...
126
        );
127
    }
128
129
    public function testBuildJoinQueryPartWhenEmpty()
130
    {
131
        $this->joinTraitClass->clearJoinData();
0 ignored issues
show
Bug introduced by
It seems like clearJoinData() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

131
        $this->joinTraitClass->/** @scrutinizer ignore-call */ 
132
                               clearJoinData();
Loading history...
132
133
        $this->assertEquals(null, $this->joinTraitClass->buildJoinQueryPartPublic());
134
    }
135
136
    /**
137
     *
138
     * @return array
139
     */
140
    public function joinData()
141
    {
142
        return [
143
            [
144
                JoinEnum::LEFT_JOIN,
145
                'table3',
146
                'table3.id = table1.table3_id',
147
                []
148
            ],
149
            [
150
                JoinEnum::LEFT_JOIN,
151
                'table4',
152
                'table4.id = table1.table4_id AND table4.column = :table4_column',
153
                [
154
                    'table4_column' => 'value',
155
                ]
156
            ],
157
            [
158
                JoinEnum::INNER_JOIN,
159
                'table5',
160
                'table5.id = table1.table5_id',
161
                []
162
            ],
163
            [
164
                JoinEnum::INNER_JOIN,
165
                'table6',
166
                'table6.id = table1.table6_id AND table6.column = :table6_column',
167
                [
168
                    'table6_column' => 'value',
169
                ]
170
            ],
171
            [
172
                JoinEnum::FULL_OUTER_JOIN,
173
                'table7',
174
                'table7.id = table1.table7_id',
175
                []
176
            ],
177
            [
178
                JoinEnum::FULL_OUTER_JOIN,
179
                'table8',
180
                'table8.id = table1.table8_id AND table8.column = :table8_column',
181
                [
182
                    'table8_column' => 'value',
183
                ]
184
            ],
185
            [
186
                JoinEnum::RIGHT_JOIN,
187
                'table9',
188
                'table9.id = table1.table9_id',
189
                []
190
            ],
191
            [
192
                JoinEnum::RIGHT_JOIN,
193
                'table10',
194
                'table10.id = table1.table10_id AND table10.column = :table10_column',
195
                [
196
                    'table10_column' => 'value',
197
                ]
198
            ],
199
            [
200
                JoinEnum::CROSS_JOIN,
201
                'table11',
202
                'table11.id = table1.table11_id',
203
                []
204
            ],
205
            [
206
                JoinEnum::CROSS_JOIN,
207
                'table12',
208
                'table12.id = table1.table12_id AND table12.column = :table12_column',
209
                [
210
                    'table12_column' => 'value',
211
                ]
212
            ],
213
        ];
214
    }
215
216
    public function testJoinWithSameJoin()
217
    {
218
        $object = $this->joinTraitClass->join(
219
            static::JOIN_DEFAULT_JOIN,
220
            static::JOIN_DEFAULT_TABLE,
221
            static::JOIN_DEFAULT_ON_CONDITION,
222
            static::JOIN_BIND_DEFAULT
223
        );
224
        $this->assertObjectUsesTrait(BindTrait::class, $object);
225
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
226
        $this->assertEquals(static::JOIN_DEFAULT, $this->joinTraitClass->joinData());
227
        $this->assertEquals(static::JOIN_BIND_DEFAULT, $this->joinTraitClass->bindData());
228
    }
229
230
    public function testJoinWithInvalidJoin()
231
    {
232
        $this->expectException(QueryBuilderException::class);
233
        $this->expectExceptionMessage('$join "INVALID" is not a valid join type');
234
235
        $this->joinTraitClass->join(
236
            static::JOIN_INVALID_JOIN,
237
            static::JOIN_DEFAULT_TABLE,
238
            static::JOIN_DEFAULT_ON_CONDITION,
239
            static::JOIN_BIND_DEFAULT
240
        );
241
    }
242
243
    public function testJoinWithEmptyTable()
244
    {
245
        $this->expectException(QueryBuilderException::class);
246
        $this->expectExceptionMessage('You must pass $table name to join method!');
247
248
        $this->joinTraitClass->join(
249
            static::JOIN_DEFAULT_JOIN,
250
            static::JOIN_EMPTY_TABLE,
251
            static::JOIN_DEFAULT_ON_CONDITION,
252
            static::JOIN_BIND_DEFAULT
253
        );
254
    }
255
256
    public function testJoinWithEmptyOnCondition()
257
    {
258
        $this->expectException(QueryBuilderException::class);
259
        $this->expectExceptionMessage('You must pass $onCondition name to join method!');
260
261
        $this->joinTraitClass->join(
262
            static::JOIN_DEFAULT_JOIN,
263
            static::JOIN_DEFAULT_TABLE,
264
            static::JOIN_EMPTY_ON_CONDITION,
265
            static::JOIN_BIND_DEFAULT
266
        );
267
    }
268
269
    /**
270
     * @dataProvider joinAsData
271
     *
272
     * @param string $join
273
     * @param string $tableName
274
     * @param string $alias
275
     * @param string $onCondition
276
     * @param array $bind
277
     */
278
    public function testJoinAs($join, $tableName, $alias, $onCondition, array $bind)
279
    {
280
        $object = $this->joinTraitClass->joinAs($join, $tableName, $alias, $onCondition, $bind);
0 ignored issues
show
Bug introduced by
It seems like joinAs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

280
        /** @scrutinizer ignore-call */ 
281
        $object = $this->joinTraitClass->joinAs($join, $tableName, $alias, $onCondition, $bind);
Loading history...
281
        $this->assertObjectUsesTrait(BindTrait::class, $object);
282
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
283
        $this->assertEquals(
284
            \array_merge(
285
                static::JOIN_DEFAULT,
286
                [
287
                    \sprintf('%s %s AS %s ON (%s)', $join, $tableName, $alias, $onCondition),
288
                ]
289
            ),
290
            $this->joinTraitClass->joinData()
291
        );
292
        $this->assertEquals(
293
            \array_merge(
294
                static::JOIN_BIND_DEFAULT,
295
                $bind
296
            ),
297
            $this->joinTraitClass->bindData()
298
        );
299
    }
300
301
    /**
302
     *
303
     * @return array
304
     */
305
    public function joinAsData()
306
    {
307
        return [
308
            [
309
                JoinEnum::LEFT_JOIN,
310
                'table3',
311
                'alias_table3',
312
                'table3.id = table1.table3_id',
313
                []
314
            ],
315
            [
316
                JoinEnum::LEFT_JOIN,
317
                'table4',
318
                'alias_table4',
319
                'table4.id = table1.table4_id AND table4.column = :table4_column',
320
                [
321
                    'table4_column' => 'value',
322
                ]
323
            ],
324
            [
325
                JoinEnum::INNER_JOIN,
326
                'table5',
327
                'alias_table5',
328
                'table5.id = table1.table5_id',
329
                []
330
            ],
331
            [
332
                JoinEnum::INNER_JOIN,
333
                'table6',
334
                'alias_table6',
335
                'table6.id = table1.table6_id AND table6.column = :table6_column',
336
                [
337
                    'table6_column' => 'value',
338
                ]
339
            ],
340
            [
341
                JoinEnum::FULL_OUTER_JOIN,
342
                'table7',
343
                'alias_table7',
344
                'table7.id = table1.table7_id',
345
                []
346
            ],
347
            [
348
                JoinEnum::FULL_OUTER_JOIN,
349
                'table8',
350
                'alias_table8',
351
                'table8.id = table1.table8_id AND table8.column = :table8_column',
352
                [
353
                    'table8_column' => 'value',
354
                ]
355
            ],
356
            [
357
                JoinEnum::RIGHT_JOIN,
358
                'table9',
359
                'alias_table9',
360
                'table9.id = table1.table9_id',
361
                []
362
            ],
363
            [
364
                JoinEnum::RIGHT_JOIN,
365
                'table10',
366
                'alias_table10',
367
                'table10.id = table1.table10_id AND table10.column = :table10_column',
368
                [
369
                    'table10_column' => 'value',
370
                ]
371
            ],
372
            [
373
                JoinEnum::CROSS_JOIN,
374
                'table11',
375
                'alias_table11',
376
                'table11.id = table1.table11_id',
377
                []
378
            ],
379
            [
380
                JoinEnum::CROSS_JOIN,
381
                'table12',
382
                'alias_table12',
383
                'table12.id = table1.table12_id AND table12.column = :table12_column',
384
                [
385
                    'table12_column' => 'value',
386
                ]
387
            ],
388
        ];
389
    }
390
391
    public function testJoinAsWithEmptyAlias()
392
    {
393
        $this->expectException(QueryBuilderException::class);
394
        $this->expectExceptionMessage('You must pass $alias name to join method!');
395
396
        $this->joinTraitClass->joinAs(
397
            static::JOIN_DEFAULT_JOIN,
398
            static::JOIN_DEFAULT_TABLE,
399
            static::JOIN_EMPTY_ALIAS,
400
            static::JOIN_EMPTY_ON_CONDITION,
401
            static::JOIN_BIND_DEFAULT
402
        );
403
    }
404
405
    public function testInnerJoin()
406
    {
407
        $object = $this->joinTraitClass->innerJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
0 ignored issues
show
Bug introduced by
It seems like innerJoin() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

407
        /** @scrutinizer ignore-call */ 
408
        $object = $this->joinTraitClass->innerJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
Loading history...
408
        $this->assertObjectUsesTrait(BindTrait::class, $object);
409
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
410
        $this->assertEquals(
411
            \array_merge(
412
                static::JOIN_DEFAULT,
413
                [
414
                    \sprintf('%s %s ON (%s)', JoinEnum::INNER_JOIN, static::JOIN_TABLE, static::JOIN_ON_CONDITION),
415
                ]
416
            ),
417
            $this->joinTraitClass->joinData()
418
        );
419
        $this->assertEquals(
420
            \array_merge(
421
                static::JOIN_BIND_DEFAULT,
422
                static::JOIN_BIND
423
            ),
424
            $this->joinTraitClass->bindData()
425
        );
426
    }
427
428
    public function testInnerJoinAs()
429
    {
430
        $object = $this->joinTraitClass->innerJoinAs(
0 ignored issues
show
Bug introduced by
It seems like innerJoinAs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

430
        /** @scrutinizer ignore-call */ 
431
        $object = $this->joinTraitClass->innerJoinAs(
Loading history...
431
            static::JOIN_TABLE,
432
            static::JOIN_TABLE_ALIAS,
433
            static::JOIN_ON_CONDITION,
434
            static::JOIN_BIND
435
        );
436
        $this->assertObjectUsesTrait(BindTrait::class, $object);
437
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
438
        $this->assertEquals(
439
            \array_merge(
440
                static::JOIN_DEFAULT,
441
                [
442
                    \sprintf(
443
                        '%s %s AS %s ON (%s)',
444
                        JoinEnum::INNER_JOIN,
445
                        static::JOIN_TABLE,
446
                        static::JOIN_TABLE_ALIAS,
447
                        static::JOIN_ON_CONDITION
448
                    ),
449
                ]
450
            ),
451
            $this->joinTraitClass->joinData()
452
        );
453
        $this->assertEquals(
454
            \array_merge(
455
                static::JOIN_BIND_DEFAULT,
456
                static::JOIN_BIND
457
            ),
458
            $this->joinTraitClass->bindData()
459
        );
460
    }
461
462
    public function testLeftJoin()
463
    {
464
        $object = $this->joinTraitClass->leftJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
0 ignored issues
show
Bug introduced by
It seems like leftJoin() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

464
        /** @scrutinizer ignore-call */ 
465
        $object = $this->joinTraitClass->leftJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
Loading history...
465
        $this->assertObjectUsesTrait(BindTrait::class, $object);
466
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
467
        $this->assertEquals(
468
            \array_merge(
469
                static::JOIN_DEFAULT,
470
                [
471
                    \sprintf('%s %s ON (%s)', JoinEnum::LEFT_JOIN, static::JOIN_TABLE, static::JOIN_ON_CONDITION),
472
                ]
473
            ),
474
            $this->joinTraitClass->joinData()
475
        );
476
        $this->assertEquals(
477
            \array_merge(
478
                static::JOIN_BIND_DEFAULT,
479
                static::JOIN_BIND
480
            ),
481
            $this->joinTraitClass->bindData()
482
        );
483
    }
484
485
    public function testLeftJoinAs()
486
    {
487
        $object = $this->joinTraitClass->leftJoinAs(
0 ignored issues
show
Bug introduced by
It seems like leftJoinAs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

487
        /** @scrutinizer ignore-call */ 
488
        $object = $this->joinTraitClass->leftJoinAs(
Loading history...
488
            static::JOIN_TABLE,
489
            static::JOIN_TABLE_ALIAS,
490
            static::JOIN_ON_CONDITION,
491
            static::JOIN_BIND
492
        );
493
        $this->assertObjectUsesTrait(BindTrait::class, $object);
494
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
495
        $this->assertEquals(
496
            \array_merge(
497
                static::JOIN_DEFAULT,
498
                [
499
                    \sprintf(
500
                        '%s %s AS %s ON (%s)',
501
                        JoinEnum::LEFT_JOIN,
502
                        static::JOIN_TABLE,
503
                        static::JOIN_TABLE_ALIAS,
504
                        static::JOIN_ON_CONDITION
505
                    ),
506
                ]
507
            ),
508
            $this->joinTraitClass->joinData()
509
        );
510
        $this->assertEquals(
511
            \array_merge(
512
                static::JOIN_BIND_DEFAULT,
513
                static::JOIN_BIND
514
            ),
515
            $this->joinTraitClass->bindData()
516
        );
517
    }
518
519
    public function testRightJoin()
520
    {
521
        $object = $this->joinTraitClass->rightJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
0 ignored issues
show
Bug introduced by
It seems like rightJoin() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

521
        /** @scrutinizer ignore-call */ 
522
        $object = $this->joinTraitClass->rightJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
Loading history...
522
        $this->assertObjectUsesTrait(BindTrait::class, $object);
523
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
524
        $this->assertEquals(
525
            \array_merge(
526
                static::JOIN_DEFAULT,
527
                [
528
                    \sprintf('%s %s ON (%s)', JoinEnum::RIGHT_JOIN, static::JOIN_TABLE, static::JOIN_ON_CONDITION),
529
                ]
530
            ),
531
            $this->joinTraitClass->joinData()
532
        );
533
        $this->assertEquals(
534
            \array_merge(
535
                static::JOIN_BIND_DEFAULT,
536
                static::JOIN_BIND
537
            ),
538
            $this->joinTraitClass->bindData()
539
        );
540
    }
541
542
    public function testRightJoinAs()
543
    {
544
        $object = $this->joinTraitClass->rightJoinAs(
0 ignored issues
show
Bug introduced by
It seems like rightJoinAs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

544
        /** @scrutinizer ignore-call */ 
545
        $object = $this->joinTraitClass->rightJoinAs(
Loading history...
545
            static::JOIN_TABLE,
546
            static::JOIN_TABLE_ALIAS,
547
            static::JOIN_ON_CONDITION,
548
            static::JOIN_BIND
549
        );
550
        $this->assertObjectUsesTrait(BindTrait::class, $object);
551
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
552
        $this->assertEquals(
553
            \array_merge(
554
                static::JOIN_DEFAULT,
555
                [
556
                    \sprintf(
557
                        '%s %s AS %s ON (%s)',
558
                        JoinEnum::RIGHT_JOIN,
559
                        static::JOIN_TABLE,
560
                        static::JOIN_TABLE_ALIAS,
561
                        static::JOIN_ON_CONDITION
562
                    ),
563
                ]
564
            ),
565
            $this->joinTraitClass->joinData()
566
        );
567
        $this->assertEquals(
568
            \array_merge(
569
                static::JOIN_BIND_DEFAULT,
570
                static::JOIN_BIND
571
            ),
572
            $this->joinTraitClass->bindData()
573
        );
574
    }
575
576
    public function testCrossJoin()
577
    {
578
        $object = $this->joinTraitClass->crossJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
0 ignored issues
show
Bug introduced by
It seems like crossJoin() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

578
        /** @scrutinizer ignore-call */ 
579
        $object = $this->joinTraitClass->crossJoin(static::JOIN_TABLE, static::JOIN_ON_CONDITION, static::JOIN_BIND);
Loading history...
579
        $this->assertObjectUsesTrait(BindTrait::class, $object);
580
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
581
        $this->assertEquals(
582
            \array_merge(
583
                static::JOIN_DEFAULT,
584
                [
585
                    \sprintf('%s %s ON (%s)', JoinEnum::CROSS_JOIN, static::JOIN_TABLE, static::JOIN_ON_CONDITION),
586
                ]
587
            ),
588
            $this->joinTraitClass->joinData()
589
        );
590
        $this->assertEquals(
591
            \array_merge(
592
                static::JOIN_BIND_DEFAULT,
593
                static::JOIN_BIND
594
            ),
595
            $this->joinTraitClass->bindData()
596
        );
597
    }
598
599
    public function testCrossJoinAs()
600
    {
601
        $object = $this->joinTraitClass->crossJoinAs(
0 ignored issues
show
Bug introduced by
It seems like crossJoinAs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

601
        /** @scrutinizer ignore-call */ 
602
        $object = $this->joinTraitClass->crossJoinAs(
Loading history...
602
            static::JOIN_TABLE,
603
            static::JOIN_TABLE_ALIAS,
604
            static::JOIN_ON_CONDITION,
605
            static::JOIN_BIND
606
        );
607
        $this->assertObjectUsesTrait(BindTrait::class, $object);
608
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
609
        $this->assertEquals(
610
            \array_merge(
611
                static::JOIN_DEFAULT,
612
                [
613
                    \sprintf(
614
                        '%s %s AS %s ON (%s)',
615
                        JoinEnum::CROSS_JOIN,
616
                        static::JOIN_TABLE,
617
                        static::JOIN_TABLE_ALIAS,
618
                        static::JOIN_ON_CONDITION
619
                    ),
620
                ]
621
            ),
622
            $this->joinTraitClass->joinData()
623
        );
624
        $this->assertEquals(
625
            \array_merge(
626
                static::JOIN_BIND_DEFAULT,
627
                static::JOIN_BIND
628
            ),
629
            $this->joinTraitClass->bindData()
630
        );
631
    }
632
633
    public function testFullOuterJoin()
634
    {
635
        $object = $this->joinTraitClass->fullOuterJoin(
0 ignored issues
show
Bug introduced by
It seems like fullOuterJoin() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

635
        /** @scrutinizer ignore-call */ 
636
        $object = $this->joinTraitClass->fullOuterJoin(
Loading history...
636
            static::JOIN_TABLE,
637
            static::JOIN_ON_CONDITION,
638
            static::JOIN_BIND
639
        );
640
        $this->assertObjectUsesTrait(BindTrait::class, $object);
641
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
642
        $this->assertEquals(
643
            \array_merge(
644
                static::JOIN_DEFAULT,
645
                [
646
                    \sprintf('%s %s ON (%s)', JoinEnum::FULL_OUTER_JOIN, static::JOIN_TABLE, static::JOIN_ON_CONDITION),
647
                ]
648
            ),
649
            $this->joinTraitClass->joinData()
650
        );
651
        $this->assertEquals(
652
            \array_merge(
653
                static::JOIN_BIND_DEFAULT,
654
                static::JOIN_BIND
655
            ),
656
            $this->joinTraitClass->bindData()
657
        );
658
    }
659
660
    public function testFullOuterJoinAs()
661
    {
662
        $object = $this->joinTraitClass->fullOuterJoinAs(
0 ignored issues
show
Bug introduced by
It seems like fullOuterJoinAs() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

662
        /** @scrutinizer ignore-call */ 
663
        $object = $this->joinTraitClass->fullOuterJoinAs(
Loading history...
663
            static::JOIN_TABLE,
664
            static::JOIN_TABLE_ALIAS,
665
            static::JOIN_ON_CONDITION,
666
            static::JOIN_BIND
667
        );
668
        $this->assertObjectUsesTrait(BindTrait::class, $object);
669
        $this->assertObjectUsesTrait(JoinTrait::class, $object);
670
        $this->assertEquals(
671
            \array_merge(
672
                static::JOIN_DEFAULT,
673
                [
674
                    \sprintf(
675
                        '%s %s AS %s ON (%s)',
676
                        JoinEnum::FULL_OUTER_JOIN,
677
                        static::JOIN_TABLE,
678
                        static::JOIN_TABLE_ALIAS,
679
                        static::JOIN_ON_CONDITION
680
                    ),
681
                ]
682
            ),
683
            $this->joinTraitClass->joinData()
684
        );
685
        $this->assertEquals(
686
            \array_merge(
687
                static::JOIN_BIND_DEFAULT,
688
                static::JOIN_BIND
689
            ),
690
            $this->joinTraitClass->bindData()
691
        );
692
    }
693
}
694