1 | <?php |
||||
2 | |||||
3 | namespace Nip\Database\Tests\Query; |
||||
4 | |||||
5 | use Mockery as m; |
||||
6 | use Nip\Database\Connections\Connection; |
||||
7 | use Nip\Database\Query\Insert; |
||||
8 | use Nip\Database\Tests\AbstractTest; |
||||
9 | |||||
10 | /** |
||||
11 | * Class InsertTest |
||||
12 | * @package Nip\Database\Tests\Query |
||||
13 | */ |
||||
14 | class InsertTest extends AbstractTest |
||||
15 | { |
||||
16 | /** |
||||
17 | * @var \UnitTester |
||||
0 ignored issues
–
show
|
|||||
18 | */ |
||||
19 | protected $tester; |
||||
20 | |||||
21 | /** |
||||
22 | * @var Insert |
||||
23 | */ |
||||
24 | protected $object; |
||||
25 | |||||
26 | public function test_null() |
||||
27 | { |
||||
28 | $this->object->table("table"); |
||||
0 ignored issues
–
show
'table' of type string is incompatible with the type array expected by parameter $| of Nip\Database\Query\AbstractQuery::table() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
29 | $this->object->data(["id" => 3, "name" => null]); |
||||
30 | |||||
31 | static::assertEquals( |
||||
32 | "INSERT INTO `table` (`id`,`name`) VALUES (3, NULL)", |
||||
33 | $this->object->assemble() |
||||
34 | ); |
||||
35 | } |
||||
36 | |||||
37 | public function testOnDuplicate() |
||||
38 | { |
||||
39 | $this->object->table("table"); |
||||
0 ignored issues
–
show
'table' of type string is incompatible with the type array expected by parameter $| of Nip\Database\Query\AbstractQuery::table() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
40 | $this->object->data(["id" => 3, "name" => "Lorem Ipsum"]); |
||||
41 | $this->object->onDuplicate([ |
||||
42 | "id" => ["VALUES(`id`)", false], |
||||
43 | "name" => ["VALUES(`name`)", false] |
||||
44 | ]); |
||||
45 | |||||
46 | static::assertEquals( |
||||
47 | "INSERT INTO `table` (`id`,`name`) VALUES (3, 'Lorem Ipsum') ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`)", |
||||
48 | $this->object->assemble() |
||||
49 | ); |
||||
50 | } |
||||
51 | |||||
52 | public function testMultiple() |
||||
53 | { |
||||
54 | $this->object->table("table"); |
||||
0 ignored issues
–
show
'table' of type string is incompatible with the type array expected by parameter $| of Nip\Database\Query\AbstractQuery::table() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
55 | |||||
56 | $items = [ |
||||
57 | ["name" => "Lorem Ipsum", "telephone" => 1234], |
||||
58 | ["name" => "Dolor sit amet", "telephone" => 5678] |
||||
59 | ]; |
||||
60 | |||||
61 | foreach ($items as $item) { |
||||
62 | $this->object->data($item); |
||||
63 | } |
||||
64 | |||||
65 | static::assertEquals( |
||||
66 | "INSERT INTO `table` (`name`,`telephone`) VALUES ('Lorem Ipsum', 1234), ('Dolor sit amet', 5678)", |
||||
67 | $this->object->assemble() |
||||
68 | ); |
||||
69 | } |
||||
70 | |||||
71 | protected function setUp(): void |
||||
72 | { |
||||
73 | parent::setUp(); |
||||
74 | $this->object = new Insert(); |
||||
75 | |||||
76 | $adapterMock = m::mock('Nip\Database\Adapters\MySQLi')->shouldDeferMissing(); |
||||
0 ignored issues
–
show
The function
Mockery\LegacyMockInterface::shouldDeferMissing() has been deprecated: 2.0.0 Please use makePartial() instead
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
77 | $adapterMock->shouldReceive('cleanData')->andReturnUsing(function ($data) { |
||||
78 | return $data; |
||||
79 | }); |
||||
80 | $manager = new Connection(false); |
||||
0 ignored issues
–
show
false of type false is incompatible with the type Closure|PDO expected by parameter $pdo of Nip\Database\Connections\Connection::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
81 | $manager->setAdapter($adapterMock); |
||||
82 | $this->object->setManager($manager); |
||||
83 | } |
||||
84 | } |
||||
85 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths