From aa6dba5538d2482643cec5dacfdc343b6130ae69 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 11 Sep 2011 23:25:13 +0200 Subject: [PATCH] MDL-29321 tweak large varchar unit tests for oracle --- lib/ddl/simpletest/testddl.php | 37 +++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/ddl/simpletest/testddl.php b/lib/ddl/simpletest/testddl.php index 2266721c533..7ea1275bbd4 100644 --- a/lib/ddl/simpletest/testddl.php +++ b/lib/ddl/simpletest/testddl.php @@ -1600,11 +1600,6 @@ class ddl_test extends UnitTestCase { $DB = $this->tdb; $dbman = $DB->get_manager(); - $maxstr = ''; - for($i=0; $iadd_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('name', XMLDB_TYPE_CHAR, xmldb_field::CHAR_MAX_LENGTH, null, XMLDB_NOTNULL, null); @@ -1618,6 +1613,12 @@ class ddl_test extends UnitTestCase { $tablename = $table->getName(); $this->tables[$tablename] = $table; + // this has to work in all DBs + $maxstr = ''; + for($i=0; $iname = $maxstr; @@ -1628,6 +1629,30 @@ class ddl_test extends UnitTestCase { $this->assertIdentical($rec->name, $maxstr); + // Following test is supposed to fail in oracle + $maxstr = ''; + for($i=0; $iname = $maxstr; + + try { + $id = $DB->insert_record($tablename, $rec); + $this->assertTrue(!empty($id)); + + $rec = $DB->get_record($tablename, array('id'=>$id)); + $this->assertIdentical($rec->name, $maxstr); + } catch (dml_write_exception $e) { + if ($DB->get_dbfamily() === 'oracle') { + $this->fail('Oracle does not support text fields larger than 4000 bytes, this is not a big problem for mostly ascii based languages'); + } else { + throw $e; + } + } + + $table = new xmldb_table('testtable'); $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('name', XMLDB_TYPE_CHAR, xmldb_field::CHAR_MAX_LENGTH+1, null, XMLDB_NOTNULL, null); @@ -1637,6 +1662,8 @@ class ddl_test extends UnitTestCase { if ($dbman->table_exists($table)) { $dbman->drop_table($table); } + $tablename = $table->getName(); + $this->tables[$tablename] = $table; try { $dbman->create_table($table); -- 2.39.2