Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 162... Línea 162...
162
    }
162
    }
Línea 163... Línea 163...
163
 
163
 
164
    /**
164
    /**
165
     * Test behaviour of table_exists()
165
     * Test behaviour of table_exists()
166
     */
166
     */
167
    public function test_table_exists() {
167
    public function test_table_exists(): void {
168
        $DB = $this->tdb; // Do not use global $DB!
168
        $DB = $this->tdb; // Do not use global $DB!
Línea 169... Línea 169...
169
        $dbman = $this->tdb->get_manager();
169
        $dbman = $this->tdb->get_manager();
170
 
170
 
Línea 207... Línea 207...
207
    }
207
    }
Línea 208... Línea 208...
208
 
208
 
209
    /**
209
    /**
210
     * Test behaviour of create_table()
210
     * Test behaviour of create_table()
211
     */
211
     */
Línea 212... Línea 212...
212
    public function test_create_table() {
212
    public function test_create_table(): void {
213
 
213
 
Línea 214... Línea 214...
214
        $DB = $this->tdb; // Do not use global $DB!
214
        $DB = $this->tdb; // Do not use global $DB!
Línea 557... Línea 557...
557
    /**
557
    /**
558
     * Test if database supports tables with many TEXT fields,
558
     * Test if database supports tables with many TEXT fields,
559
     * InnoDB is known to failed during data insertion instead
559
     * InnoDB is known to failed during data insertion instead
560
     * of table creation when text fields contain actual data.
560
     * of table creation when text fields contain actual data.
561
     */
561
     */
562
    public function test_row_size_limits() {
562
    public function test_row_size_limits(): void {
Línea 563... Línea 563...
563
 
563
 
564
        $DB = $this->tdb; // Do not use global $DB!
564
        $DB = $this->tdb; // Do not use global $DB!
Línea 565... Línea 565...
565
        $dbman = $this->tdb->get_manager();
565
        $dbman = $this->tdb->get_manager();
Línea 642... Línea 642...
642
    }
642
    }
Línea 643... Línea 643...
643
 
643
 
644
    /**
644
    /**
645
     * Test behaviour of drop_table()
645
     * Test behaviour of drop_table()
646
     */
646
     */
647
    public function test_drop_table() {
647
    public function test_drop_table(): void {
648
        $DB = $this->tdb; // Do not use global $DB!
648
        $DB = $this->tdb; // Do not use global $DB!
Línea 649... Línea 649...
649
        $dbman = $this->tdb->get_manager();
649
        $dbman = $this->tdb->get_manager();
650
 
650
 
Línea 675... Línea 675...
675
    }
675
    }
Línea 676... Línea 676...
676
 
676
 
677
    /**
677
    /**
678
     * Test behaviour of rename_table()
678
     * Test behaviour of rename_table()
679
     */
679
     */
680
    public function test_rename_table() {
680
    public function test_rename_table(): void {
681
        $DB = $this->tdb; // Do not use global $DB!
681
        $DB = $this->tdb; // Do not use global $DB!
Línea 682... Línea 682...
682
        $dbman = $this->tdb->get_manager();
682
        $dbman = $this->tdb->get_manager();
Línea 710... Línea 710...
710
    }
710
    }
Línea 711... Línea 711...
711
 
711
 
712
    /**
712
    /**
713
     * Test behaviour of field_exists()
713
     * Test behaviour of field_exists()
714
     */
714
     */
715
    public function test_field_exists() {
715
    public function test_field_exists(): void {
Línea 716... Línea 716...
716
        $dbman = $this->tdb->get_manager();
716
        $dbman = $this->tdb->get_manager();
Línea 717... Línea 717...
717
 
717
 
Línea 774... Línea 774...
774
    }
774
    }
Línea 775... Línea 775...
775
 
775
 
776
    /**
776
    /**
777
     * Test behaviour of add_field()
777
     * Test behaviour of add_field()
778
     */
778
     */
779
    public function test_add_field() {
779
    public function test_add_field(): void {
780
        $DB = $this->tdb; // Do not use global $DB!
780
        $DB = $this->tdb; // Do not use global $DB!
Línea 781... Línea 781...
781
        $dbman = $this->tdb->get_manager();
781
        $dbman = $this->tdb->get_manager();
Línea 939... Línea 939...
939
    }
939
    }
Línea 940... Línea 940...
940
 
940
 
941
    /**
941
    /**
942
     * Test behaviour of drop_field()
942
     * Test behaviour of drop_field()
943
     */
943
     */
944
    public function test_drop_field() {
944
    public function test_drop_field(): void {
945
        $DB = $this->tdb; // Do not use global $DB!
945
        $DB = $this->tdb; // Do not use global $DB!
Línea 946... Línea 946...
946
        $dbman = $this->tdb->get_manager();
946
        $dbman = $this->tdb->get_manager();
Línea 996... Línea 996...
996
    }
996
    }
Línea 997... Línea 997...
997
 
997
 
998
    /**
998
    /**
999
     * Test behaviour of change_field_type()
999
     * Test behaviour of change_field_type()
1000
     */
1000
     */
1001
    public function test_change_field_type() {
1001
    public function test_change_field_type(): void {
1002
        $DB = $this->tdb; // Do not use global $DB!
1002
        $DB = $this->tdb; // Do not use global $DB!
Línea 1003... Línea 1003...
1003
        $dbman = $this->tdb->get_manager();
1003
        $dbman = $this->tdb->get_manager();
1004
 
1004
 
Línea 1156... Línea 1156...
1156
    }
1156
    }
Línea 1157... Línea 1157...
1157
 
1157
 
1158
    /**
1158
    /**
1159
     * Test behaviour of test_change_field_precision()
1159
     * Test behaviour of test_change_field_precision()
1160
     */
1160
     */
1161
    public function test_change_field_precision() {
1161
    public function test_change_field_precision(): void {
1162
        $DB = $this->tdb; // Do not use global $DB!
1162
        $DB = $this->tdb; // Do not use global $DB!
Línea 1163... Línea 1163...
1163
        $dbman = $this->tdb->get_manager();
1163
        $dbman = $this->tdb->get_manager();
Línea 1672... Línea 1672...
1672
        // Real and valid xml file.
1672
        // Real and valid xml file.
1673
        $dbman->install_from_xmldb_file(__DIR__ . '/fixtures/xmldb_table.xml');
1673
        $dbman->install_from_xmldb_file(__DIR__ . '/fixtures/xmldb_table.xml');
1674
        $this->assertTrue($dbman->table_exists('test_table1'));
1674
        $this->assertTrue($dbman->table_exists('test_table1'));
1675
    }
1675
    }
Línea 1676... Línea 1676...
1676
 
1676
 
1677
    public function test_temp_tables() {
1677
    public function test_temp_tables(): void {
1678
        $DB = $this->tdb; // Do not use global $DB!
1678
        $DB = $this->tdb; // Do not use global $DB!
Línea 1679... Línea 1679...
1679
        $dbman = $this->tdb->get_manager();
1679
        $dbman = $this->tdb->get_manager();
1680
 
1680
 
Línea 1789... Línea 1789...
1789
        // Drop temp table.
1789
        // Drop temp table.
1790
        $dbman->drop_table($table2);
1790
        $dbman->drop_table($table2);
1791
        $this->assertFalse($dbman->table_exists('test_temp'));
1791
        $this->assertFalse($dbman->table_exists('test_temp'));
1792
    }
1792
    }
Línea 1793... Línea 1793...
1793
 
1793
 
1794
    public function test_concurrent_temp_tables() {
1794
    public function test_concurrent_temp_tables(): void {
1795
        $DB = $this->tdb; // Do not use global $DB!
1795
        $DB = $this->tdb; // Do not use global $DB!
Línea 1796... Línea 1796...
1796
        $dbman = $this->tdb->get_manager();
1796
        $dbman = $this->tdb->get_manager();
1797
 
1797
 
Línea 1837... Línea 1837...
1837
    }
1837
    }
Línea 1838... Línea 1838...
1838
 
1838
 
1839
    /**
1839
    /**
1840
     * get_columns should return an empty array for ex-temptables.
1840
     * get_columns should return an empty array for ex-temptables.
1841
     */
1841
     */
1842
    public function test_leftover_temp_tables_columns() {
1842
    public function test_leftover_temp_tables_columns(): void {
1843
        $DB = $this->tdb; // Do not use global $DB!
1843
        $DB = $this->tdb; // Do not use global $DB!
Línea 1844... Línea 1844...
1844
        $dbman = $this->tdb->get_manager();
1844
        $dbman = $this->tdb->get_manager();
1845
 
1845
 
Línea 1855... Línea 1855...
1855
    }
1855
    }
Línea 1856... Línea 1856...
1856
 
1856
 
1857
    /**
1857
    /**
1858
     * Deleting a temp table should not purge the whole cache
1858
     * Deleting a temp table should not purge the whole cache
1859
     */
1859
     */
1860
    public function test_leftover_temp_tables_cache() {
1860
    public function test_leftover_temp_tables_cache(): void {
1861
        $DB = $this->tdb; // Do not use global $DB!
1861
        $DB = $this->tdb; // Do not use global $DB!
Línea 1862... Línea 1862...
1862
        $dbman = $this->tdb->get_manager();
1862
        $dbman = $this->tdb->get_manager();
1863
 
1863
 
Línea 1902... Línea 1902...
1902
 
1902
 
1903
        // Delete the leftover temp table.
1903
        // Delete the leftover temp table.
1904
        $dbman->drop_table($table1);
1904
        $dbman->drop_table($table1);
Línea 1905... Línea 1905...
1905
    }
1905
    }
1906
 
1906
 
1907
    public function test_reset_sequence() {
1907
    public function test_reset_sequence(): void {
Línea 1908... Línea 1908...
1908
        $DB = $this->tdb;
1908
        $DB = $this->tdb;
1909
        $dbman = $DB->get_manager();
1909
        $dbman = $DB->get_manager();
Línea 1941... Línea 1941...
1941
        $this->assertEquals(667, $DB->insert_record('testtable', (object)array('course'=>13)));
1941
        $this->assertEquals(667, $DB->insert_record('testtable', (object)array('course'=>13)));
Línea 1942... Línea 1942...
1942
 
1942
 
1943
        $dbman->drop_table($table);
1943
        $dbman->drop_table($table);
Línea 1944... Línea 1944...
1944
    }
1944
    }
1945
 
1945
 
1946
    public function test_reserved_words() {
1946
    public function test_reserved_words(): void {
1947
        $reserved = sql_generator::getAllReservedWords();
1947
        $reserved = sql_generator::getAllReservedWords();
Línea 1948... Línea 1948...
1948
        $this->assertTrue(count($reserved) > 1);
1948
        $this->assertTrue(count($reserved) > 1);
1949
    }
1949
    }
1950
 
1950
 
Línea 1951... Línea 1951...
1951
    public function test_index_hints() {
1951
    public function test_index_hints(): void {
1952
        $DB = $this->tdb;
1952
        $DB = $this->tdb;
Línea 1990... Línea 1990...
1990
        $table = new xmldb_table('testtable');
1990
        $table = new xmldb_table('testtable');
1991
        $index = new xmldb_index('path', XMLDB_INDEX_UNIQUE, array('path'), array('varchar_pattern_ops'));
1991
        $index = new xmldb_index('path', XMLDB_INDEX_UNIQUE, array('path'), array('varchar_pattern_ops'));
1992
        $this->assertTrue($dbman->index_exists($table, $index));
1992
        $this->assertTrue($dbman->index_exists($table, $index));
1993
    }
1993
    }
Línea 1994... Línea 1994...
1994
 
1994
 
1995
    public function test_index_max_bytes() {
1995
    public function test_index_max_bytes(): void {
1996
        $DB = $this->tdb;
1996
        $DB = $this->tdb;
Línea 1997... Línea 1997...
1997
        $dbman = $DB->get_manager();
1997
        $dbman = $DB->get_manager();
1998
 
1998
 
Línea 2038... Línea 2038...
2038
        } catch (\moodle_exception $e) {
2038
        } catch (\moodle_exception $e) {
2039
            $this->assertInstanceOf('coding_exception', $e);
2039
            $this->assertInstanceOf('coding_exception', $e);
2040
        }
2040
        }
2041
    }
2041
    }
Línea 2042... Línea 2042...
2042
 
2042
 
2043
    public function test_index_composed_max_bytes() {
2043
    public function test_index_composed_max_bytes(): void {
2044
        $DB = $this->tdb;
2044
        $DB = $this->tdb;
Línea 2045... Línea 2045...
2045
        $dbman = $DB->get_manager();
2045
        $dbman = $DB->get_manager();
2046
 
2046
 
Línea 2097... Línea 2097...
2097
        } catch (\moodle_exception $e) {
2097
        } catch (\moodle_exception $e) {
2098
            $this->assertInstanceOf('coding_exception', $e);
2098
            $this->assertInstanceOf('coding_exception', $e);
2099
        }
2099
        }
2100
    }
2100
    }
Línea 2101... Línea 2101...
2101
 
2101
 
2102
    public function test_char_size_limit() {
2102
    public function test_char_size_limit(): void {
2103
        $DB = $this->tdb;
2103
        $DB = $this->tdb;
Línea 2104... Línea 2104...
2104
        $dbman = $DB->get_manager();
2104
        $dbman = $DB->get_manager();
2105
 
2105
 
Línea 2172... Línea 2172...
2172
        } catch (\moodle_exception $e) {
2172
        } catch (\moodle_exception $e) {
2173
            $this->assertInstanceOf('coding_exception', $e);
2173
            $this->assertInstanceOf('coding_exception', $e);
2174
        }
2174
        }
2175
    }
2175
    }
Línea 2176... Línea 2176...
2176
 
2176
 
2177
    public function test_object_name() {
2177
    public function test_object_name(): void {
Línea 2178... Línea 2178...
2178
        $gen = $this->tdb->get_manager()->generator;
2178
        $gen = $this->tdb->get_manager()->generator;
2179
 
2179
 
2180
        // This will form short object name and max length should not be exceeded.
2180
        // This will form short object name and max length should not be exceeded.
Línea 2280... Línea 2280...
2280
     *
2280
     *
2281
     * @dataProvider get_enc_quoted_provider
2281
     * @dataProvider get_enc_quoted_provider
2282
     * @param bool $reserved Whether the column name is reserved or not.
2282
     * @param bool $reserved Whether the column name is reserved or not.
2283
     * @param string $columnname The column name to be quoted, according to the value of $reserved.
2283
     * @param string $columnname The column name to be quoted, according to the value of $reserved.
2284
     **/
2284
     **/
2285
    public function test_get_enc_quoted($reserved, $columnname) {
2285
    public function test_get_enc_quoted($reserved, $columnname): void {
2286
        $DB = $this->tdb;
2286
        $DB = $this->tdb;
2287
        $gen = $DB->get_manager()->generator;
2287
        $gen = $DB->get_manager()->generator;
Línea 2288... Línea 2288...
2288
 
2288
 
2289
        if (!$reserved) {
2289
        if (!$reserved) {
Línea 2329... Línea 2329...
2329
     * @dataProvider sql_generator_get_rename_field_sql_provider
2329
     * @dataProvider sql_generator_get_rename_field_sql_provider
2330
     * @param bool $reserved Whether the column name is reserved or not.
2330
     * @param bool $reserved Whether the column name is reserved or not.
2331
     * @param string $oldcolumnname The column name to be renamed.
2331
     * @param string $oldcolumnname The column name to be renamed.
2332
     * @param string $newcolumnname The new column name.
2332
     * @param string $newcolumnname The new column name.
2333
     **/
2333
     **/
2334
    public function test_sql_generator_get_rename_field_sql($reserved, $oldcolumnname, $newcolumnname) {
2334
    public function test_sql_generator_get_rename_field_sql($reserved, $oldcolumnname, $newcolumnname): void {
2335
        $DB = $this->tdb;
2335
        $DB = $this->tdb;
2336
        $gen = $DB->get_manager()->generator;
2336
        $gen = $DB->get_manager()->generator;
2337
        $prefix = $DB->get_prefix();
2337
        $prefix = $DB->get_prefix();
Línea 2338... Línea 2338...
2338
 
2338
 
Línea 2398... Línea 2398...
2398
                    break;
2398
                    break;
2399
            }
2399
            }
2400
        }
2400
        }
2401
    }
2401
    }
Línea 2402... Línea 2402...
2402
 
2402
 
2403
    public function test_get_nullable_fields_in_index() {
2403
    public function test_get_nullable_fields_in_index(): void {
2404
        $DB = $this->tdb;
2404
        $DB = $this->tdb;
Línea 2405... Línea 2405...
2405
        $gen = $DB->get_manager()->generator;
2405
        $gen = $DB->get_manager()->generator;
2406
 
2406
 
Línea 2448... Línea 2448...
2448
    */
2448
    */
Línea 2449... Línea 2449...
2449
 
2449
 
2450
    /**
2450
    /**
2451
     * Tests check_database_schema().
2451
     * Tests check_database_schema().
2452
     */
2452
     */
2453
    public function test_check_database_schema() {
2453
    public function test_check_database_schema(): void {
Línea 2454... Línea 2454...
2454
        global $CFG, $DB;
2454
        global $CFG, $DB;
Línea 2455... Línea 2455...
2455
 
2455