Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
9f321540
Unverified
Commit
9f321540
authored
Dec 31, 2017
by
Adrien Crivelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Independent tests for introspection and insert
parent
87c417fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
26 deletions
+38
-26
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+38
-26
No files found.
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
9f321540
...
@@ -1407,43 +1407,55 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
...
@@ -1407,43 +1407,55 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
*
*
* @return array
* @return array
*/
*/
p
ublic
function
getEscapedLiterals
()
:
array
p
rivate
function
getEscapedLiterals
()
:
array
{
{
return
[
return
[
'An ASCII NUL (X\'00\')'
=>
[
"
\\
0
"
],
[
'An ASCII NUL (X\'00\')'
,
"foo
\\
0bar
"
],
'Single quote, C-style'
=>
[
"
\\
'
"
],
[
'Single quote, C-style'
,
"foo
\\
'bar
"
],
'Single quote, doubled-style'
=>
[
"''
"
],
[
'Single quote, doubled-style'
,
"foo''bar
"
],
'Double quote, C-style'
=>
[
'\\"
'
],
[
'Double quote, C-style'
,
'foo\\"bar
'
],
'Double quote, double-style'
=>
[
'""
'
],
[
'Double quote, double-style'
,
'foo""bar
'
],
'Backspace'
=>
[
'\\b
'
],
[
'Backspace'
,
'foo\\bbar
'
],
'New-line'
=>
[
'\\n
'
],
[
'New-line'
,
'foo\\nbar
'
],
'Carriage return'
=>
[
'\\
r'
],
[
'Carriage return'
,
'foo\\rba
r'
],
'Tab'
=>
[
'\\t
'
],
[
'Tab'
,
'foo\\tbar
'
],
'ASCII 26 (Control+Z)'
=>
[
'\\Z
'
],
[
'ASCII 26 (Control+Z)'
,
'foo\\Zbar
'
],
'Backslash (\)'
=>
[
'\\\\
'
],
[
'Backslash (\)'
,
'foo\\\\bar
'
],
'Percent (%)'
=>
[
'\\%
'
],
[
'Percent (%)'
,
'foo\\%bar
'
],
'Underscore (_)'
=>
[
'\\_
'
],
[
'Underscore (_)'
,
'foo\\_bar
'
],
];
];
}
}
/**
private
function
createTableForDefaultValues
()
:
void
* @dataProvider getEscapedLiterals
*
* @param string $value
*/
public
function
testEscapedDefaultValueMustBePreserved
(
string
$value
)
:
void
{
{
$value
=
'foo'
.
$value
.
'bar'
;
$table
=
new
Table
(
'string_escaped_default_value'
);
$table
=
new
Table
(
'string_escaped_default_value'
);
$table
->
addColumn
(
'def_string'
,
'string'
,
array
(
'default'
=>
$value
));
foreach
(
$this
->
getEscapedLiterals
()
as
$i
=>
$literal
)
{
$table
->
addColumn
(
'field'
.
$i
,
'string'
,
[
'default'
=>
$literal
[
1
]]);
}
$table
->
addColumn
(
'def_foo'
,
'string'
);
$table
->
addColumn
(
'def_foo'
,
'string'
);
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$this
->
_sm
->
dropAndCreateTable
(
$table
);
}
public
function
testEscapedDefaultValueCanBeIntrospected
()
:
void
{
$this
->
createTableForDefaultValues
();
$onlineTable
=
$this
->
_sm
->
listTableDetails
(
'string_escaped_default_value'
);
$onlineTable
=
$this
->
_sm
->
listTableDetails
(
'string_escaped_default_value'
);
self
::
assertSame
(
$value
,
$onlineTable
->
getColumn
(
'def_string'
)
->
getDefault
(),
'should be able introspect the value of default'
);
foreach
(
$this
->
getEscapedLiterals
()
as
$i
=>
$literal
)
{
self
::
assertSame
(
$literal
[
1
],
$onlineTable
->
getColumn
(
'field'
.
$i
)
->
getDefault
(),
'should be able introspect the value of default for: '
.
$literal
[
0
]);
}
}
$this
->
_conn
->
insert
(
'string_escaped_default_value'
,
array
(
'def_foo'
=>
'foo'
));
public
function
testEscapedDefaultValueCanBeInserted
()
:
void
$row
=
$this
->
_conn
->
fetchAssoc
(
'SELECT def_string FROM string_escaped_default_value'
);
{
self
::
assertSame
(
$value
,
$row
[
'def_string'
],
'inserted default value should be the configured default value'
);
$this
->
createTableForDefaultValues
();
$this
->
_conn
->
insert
(
'string_escaped_default_value'
,
[
'def_foo'
=>
'foo'
]);
$row
=
$this
->
_conn
->
fetchAssoc
(
'SELECT * FROM string_escaped_default_value'
);
foreach
(
$this
->
getEscapedLiterals
()
as
$i
=>
$literal
)
{
self
::
assertSame
(
$literal
[
1
],
$row
[
'field'
.
$i
],
'inserted default value should be the configured default value for: '
.
$literal
[
0
]);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment