FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sql/tests/UpdateTest.php at master · siriusphp/sql · GitHub
siriusphp
sql
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sql
/
tests
/
UpdateTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (49 loc) · 1.54 KB
Breadcrumbs
sql
/
tests
/
UpdateTest.php
Copy path
File metadata and controls
59 lines (49 loc) · 1.54 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace
Sirius
\
Sql
\
Tests
;
use
PHPUnit
\
Framework
\
TestCase
;
use
Sirius
\
Sql
\
ConditionsEnum
;
use
Sirius
\
Sql
\
Insert
;
use
Sirius
\
Sql
\
Update
;
class
UpdateTest
extends
QueryTestCase
{
/**
* @return Update
*/
public
function
newUpdate
()
{
return
new
Update
(
$
this
->
getConnectionMock
());
}
public
function
test_statement_and_bindings
()
{
$
update
=
$
this
->
newUpdate
();
$
update
->
table
(
'
posts
'
)
->
columns
([
'
title
'
,
'
content
'
=>
'
xyz
'
,
'
publish_date
'
=>
$
update
->
raw
(
'
NOW()
'
)])
->
where
(
'
id
'
, [
10
,
11
])
->
where
(
'
title
'
,
'
abc
'
, ConditionsEnum::
STARTS_WITH
);
$
statement
=
<<<SQL
UPDATE posts
SET `title` = :title, `content` = :content, `publish_date` = NOW()
WHERE id IN (:__1__, :__2__) AND title LIKE :__3__
SQL
;
$
this
->
assertSameStatement
(
$
statement
,
$
update
->
getStatement
());
$
bindings
=
$
update
->
getBindValues
();
$
this
->
assertsame
([
'
content
'
=> [
'
xyz
'
, \
PDO
::
PARAM_STR
],
'
__1__
'
=> [
10
, \
PDO
::
PARAM_INT
],
'
__2__
'
=> [
11
, \
PDO
::
PARAM_INT
],
'
__3__
'
=> [
'
abc%
'
, \
PDO
::
PARAM_STR
],
],
$
update
->
getBindValues
());
$
this
->
assertTrue
(
$
update
->
hasColumns
());
$
expectedSql
=
<<<SQL
# UPDATE posts
# SET
# `title` = NULL,
# `content` = 'xyz',
# `publish_date` = NOW()
# WHERE
# id IN (10, 11)
# AND title LIKE 'abc%'
SQL
;
$
this
->
assertEquals
(
str_replace
(
"\r"
,
""
,
$
expectedSql
),
str_replace
(
"\r"
,
""
,
$
update
->
__toString
()));
}
}
Back
|
FazBrowse Home
|
New Git URL