1
1
<?php
2
+ declare (strict_types=1 );
2
3
3
4
namespace Itosho \EasyQuery \Test \TestCase \Model \Behavior ;
4
5
@@ -28,7 +29,7 @@ class UpsertBehaviorTest extends TestCase
28
29
/**
29
30
* {@inheritDoc}
30
31
*/
31
- public function setUp ()
32
+ public function setUp (): void
32
33
{
33
34
parent ::setUp ();
34
35
$ this ->Tags = TableRegistry::getTableLocator ()->get ('Itosho/EasyQuery.Tags ' );
@@ -41,7 +42,7 @@ public function setUp()
41
42
/**
42
43
* {@inheritDoc}
43
44
*/
44
- public function tearDown ()
45
+ public function tearDown (): void
45
46
{
46
47
parent ::tearDown ();
47
48
TableRegistry::getTableLocator ()->clear ();
@@ -237,12 +238,13 @@ public function testUpsertNoBeforeSave()
237
238
/**
238
239
* upsert() test when invalid update columns
239
240
*
240
- * @expectedException \LogicException
241
- * @expectedExceptionMessage config updateColumns is invalid.
242
241
* @return void
243
242
*/
244
243
public function testUpsertInvalidUpdateColumnsConfig ()
245
244
{
245
+ $ this ->expectExceptionMessage ("config updateColumns is invalid. " );
246
+ $ this ->expectException (\LogicException::class);
247
+
246
248
$ this ->Tags ->removeBehavior ('Upsert ' );
247
249
$ this ->Tags ->addBehavior ('Itosho/EasyQuery.Upsert ' , [
248
250
'uniqueColumns ' => ['name ' ],
@@ -261,12 +263,13 @@ public function testUpsertInvalidUpdateColumnsConfig()
261
263
/**
262
264
* upsert() test when invalid unique columns
263
265
*
264
- * @expectedException \LogicException
265
- * @expectedExceptionMessage config uniqueColumns is invalid.
266
266
* @return void
267
267
*/
268
268
public function testUpsertInvalidUniqueColumnsConfig ()
269
269
{
270
+ $ this ->expectExceptionMessage ("config uniqueColumns is invalid. " );
271
+ $ this ->expectException (\LogicException::class);
272
+
270
273
$ this ->Tags ->removeBehavior ('Upsert ' );
271
274
$ this ->Tags ->addBehavior ('Itosho/EasyQuery.Upsert ' , [
272
275
'updateColumns ' => ['description ' , 'modified ' ],
@@ -434,12 +437,13 @@ public function testBulkUpsertNoBeforeSave()
434
437
/**
435
438
* bulkUpsert() test when invalid update columns
436
439
*
437
- * @expectedException \LogicException
438
- * @expectedExceptionMessage config updateColumns is invalid.
439
440
* @return void
440
441
*/
441
442
public function testBulkUpsertInvalidUpdateColumnsConfig ()
442
443
{
444
+ $ this ->expectExceptionMessage ("config updateColumns is invalid. " );
445
+ $ this ->expectException (\LogicException::class);
446
+
443
447
$ this ->Tags ->removeBehavior ('Upsert ' );
444
448
$ this ->Tags ->addBehavior ('Itosho/EasyQuery.Upsert ' );
445
449
@@ -457,12 +461,13 @@ public function testBulkUpsertInvalidUpdateColumnsConfig()
457
461
/**
458
462
* bulkUpsert() test by no data
459
463
*
460
- * @expectedException \LogicException
461
- * @expectedExceptionMessage entities has no save data.
462
464
* @return void
463
465
*/
464
466
public function testBulkUpsertNoSaveData ()
465
467
{
468
+ $ this ->expectExceptionMessage ("entities has no save data. " );
469
+ $ this ->expectException (\LogicException::class);
470
+
466
471
$ this ->Tags ->removeBehavior ('Upsert ' );
467
472
$ this ->Tags ->addBehavior ('Itosho/EasyQuery.Upsert ' , [
468
473
'updateColumns ' => ['description ' , 'modified ' ],
@@ -476,7 +481,7 @@ public function testBulkUpsertNoSaveData()
476
481
*
477
482
* @return array
478
483
*/
479
- private function getBaseInsertRecords ()
484
+ private function getBaseInsertRecords (): array
480
485
{
481
486
return [
482
487
[
@@ -499,7 +504,7 @@ private function getBaseInsertRecords()
499
504
*
500
505
* @return array
501
506
*/
502
- private function getBaseUpdateRecords ()
507
+ private function getBaseUpdateRecords (): array
503
508
{
504
509
return [
505
510
[
0 commit comments