Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
8c1288db
Commit
8c1288db
authored
Jan 10, 2017
by
Adrian Greeve
Browse files
MDL-48228 database: Unit test addition and update.
parent
0bbefd81
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/ddl/tests/ddl_test.php
View file @
8c1288db
...
...
@@ -584,7 +584,7 @@ class core_ddl_testcase extends database_driver_testcase {
$table
->
add_field
(
'id'
,
XMLDB_TYPE_INTEGER
,
'10'
,
null
,
XMLDB_NOTNULL
,
XMLDB_SEQUENCE
,
null
);
$table
->
add_field
(
'name'
,
XMLDB_TYPE_CHAR
,
'30'
,
null
,
null
,
null
,
null
);
$table
->
add_key
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'id'
));
for
(
$i
=
0
;
$i
<
1
5
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
1
2
;
$i
++
)
{
$table
->
add_field
(
'text'
.
$i
,
XMLDB_TYPE_CHAR
,
'1333'
,
null
,
null
,
null
,
null
);
$data
->
{
'text'
.
$i
}
=
$text
;
}
...
...
lib/dml/tests/dml_test.php
View file @
8c1288db
...
...
@@ -5543,6 +5543,42 @@ class core_dml_testcase extends database_driver_testcase {
$dbman
->
drop_table
(
$table
);
}
}
/**
* Test that the database has full utf8 support (4 bytes).
*/
public
function
test_four_byte_character_insertion
()
{
$DB
=
$this
->
tdb
;
if
(
$DB
->
get_dbfamily
()
===
'mysql'
&&
strpos
(
$DB
->
get_dbcollation
(),
'utf8_'
)
===
0
)
{
$this
->
markTestSkipped
(
$DB
->
get_name
()
.
' does not support 4 byte characters with only a utf8 collation.
Please change to utf8mb4 for full utf8 support.'
);
}
$dbman
=
$this
->
tdb
->
get_manager
();
$table
=
$this
->
get_test_table
();
$tablename
=
$table
->
getName
();
$table
->
add_field
(
'id'
,
XMLDB_TYPE_INTEGER
,
'10'
,
null
,
XMLDB_NOTNULL
,
XMLDB_SEQUENCE
,
null
);
$table
->
add_field
(
'name'
,
XMLDB_TYPE_CHAR
,
'255'
,
null
,
null
,
null
,
null
);
$table
->
add_field
(
'content'
,
XMLDB_TYPE_TEXT
,
'big'
,
null
,
XMLDB_NOTNULL
);
$table
->
add_key
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'id'
));
$dbman
->
create_table
(
$table
);
$data
=
array
(
'name'
=>
'Name with a four byte character 𠮟る'
,
'content'
=>
'Content with a four byte emoji 📝 memo.'
);
$insertid
=
$DB
->
insert_record
(
$tablename
,
$data
);
$result
=
$DB
->
get_record
(
$tablename
,
array
(
'id'
=>
$insertid
));
$this
->
assertEquals
(
$data
[
'name'
],
$result
->
name
);
$this
->
assertEquals
(
$data
[
'content'
],
$result
->
content
);
$dbman
->
drop_table
(
$table
);
}
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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