From ca65d686febefc4a1ac8ac64739ae04ef31d60b7 Mon Sep 17 00:00:00 2001 From: Yasitha Pandithawatta Date: Tue, 14 Aug 2012 20:06:31 +0530 Subject: [PATCH] Test classes for engines library --- test/engines/PMA_StorageEngine_bdb_test.php | 125 ++++++ .../engines/PMA_StorageEngine_binlog_test.php | 68 ++++ .../engines/PMA_StorageEngine_innodb_test.php | 367 ++++++++++++++++++ 3 files changed, 560 insertions(+) create mode 100644 test/engines/PMA_StorageEngine_bdb_test.php create mode 100644 test/engines/PMA_StorageEngine_binlog_test.php create mode 100644 test/engines/PMA_StorageEngine_innodb_test.php diff --git a/test/engines/PMA_StorageEngine_bdb_test.php b/test/engines/PMA_StorageEngine_bdb_test.php new file mode 100644 index 0000000000..fc759bf7c5 --- /dev/null +++ b/test/engines/PMA_StorageEngine_bdb_test.php @@ -0,0 +1,125 @@ + 'table1', + 'engine' => 'table`2' + ); + } + } + $this->object = $this->getMockForAbstractClass('PMA_StorageEngine_bdb', array('dummy')); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getVariables + */ + public function testGetVariables(){ + $this->assertEquals( + $this->object->getVariables(), + array( + 'version_bdb' => array( + 'title' => __('Version information'), + ), + 'bdb_cache_size' => array( + 'type' => 1, + ), + 'bdb_home' => array( + ), + 'bdb_log_buffer_size' => array( + 'type' => 1, + ), + 'bdb_logdir' => array( + ), + 'bdb_max_lock' => array( + 'type' => 2, + ), + 'bdb_shared_data' => array( + ), + 'bdb_tmpdir' => array( + ), + 'bdb_data_direct' => array( + ), + 'bdb_lock_detect' => array( + ), + 'bdb_log_direct' => array( + ), + 'bdb_no_recover' => array( + ), + 'bdb_no_sync' => array( + ), + 'skip_sync_bdb_logs' => array( + ), + 'sync_bdb_logs' => array( + ), + ) + ); + } + + /** + * Test for getVariablesLikePattern + */ + public function testGetVariablesLikePattern(){ + $this->assertEquals( + $this->object->getVariablesLikePattern(), + '%bdb%' + ); + } + + /** + * Test for getMysqlHelpPage + */ + public function testGetMysqlHelpPage(){ + $this->assertEquals( + $this->object->getMysqlHelpPage(), + 'bdb' + ); + + } +} diff --git a/test/engines/PMA_StorageEngine_binlog_test.php b/test/engines/PMA_StorageEngine_binlog_test.php new file mode 100644 index 0000000000..e091383b7f --- /dev/null +++ b/test/engines/PMA_StorageEngine_binlog_test.php @@ -0,0 +1,68 @@ + 'table1', + 'engine' => 'table`2' + ); + } + } + $this->object = $this->getMockForAbstractClass('PMA_StorageEngine_binlog', array('dummy')); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + + /** + * Test for getMysqlHelpPage + */ + public function testGetMysqlHelpPage(){ + $this->assertEquals( + $this->object->getMysqlHelpPage(), + 'binary-log' + ); + } +} diff --git a/test/engines/PMA_StorageEngine_innodb_test.php b/test/engines/PMA_StorageEngine_innodb_test.php new file mode 100644 index 0000000000..b944cfd8e7 --- /dev/null +++ b/test/engines/PMA_StorageEngine_innodb_test.php @@ -0,0 +1,367 @@ + 'table1', + 'engine' => 'table`2', + 'Innodb_buffer_pool_pages_total' => 10, + 'Innodb_page_size' => 4, + 'Innodb_buffer_pool_pages_free' => 4, + 'Innodb_buffer_pool_pages_dirty' => 3, + 'Innodb_buffer_pool_pages_data' => 2, + 'Innodb_buffer_pool_pages_flushed' => 5, + 'Innodb_buffer_pool_pages_misc' => 1, + 'Innodb_buffer_pool_pages_latched' => 2, + 'Innodb_buffer_pool_read_requests' => 3, + 'Innodb_buffer_pool_write_requests' => 4, + 'Innodb_buffer_pool_reads' => 4, + 'Innodb_buffer_pool_wait_free' => 3, + ); + } + } + $this->object = $this->getMockForAbstractClass('PMA_StorageEngine_innodb', array('dummy')); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + unset($this->object); + } + + /** + * Test for getVariables + */ + public function testGetVariables(){ + $this->assertEquals( + $this->object->getVariables(), + array( + 'innodb_data_home_dir' => array( + 'title' => __('Data home directory'), + 'desc' => __('The common part of the directory path for all InnoDB data files.'), + ), + 'innodb_data_file_path' => array( + 'title' => __('Data files'), + ), + 'innodb_autoextend_increment' => array( + 'title' => __('Autoextend increment'), + 'desc' => __('The increment size for extending the size of an autoextending tablespace when it becomes full.'), + 'type' => 2, + ), + 'innodb_buffer_pool_size' => array( + 'title' => __('Buffer pool size'), + 'desc' => __('The size of the memory buffer InnoDB uses to cache data and indexes of its tables.'), + 'type' => 1, + ), + 'innodb_additional_mem_pool_size' => array( + 'title' => 'innodb_additional_mem_pool_size', + 'type' => 1, + ), + 'innodb_buffer_pool_awe_mem_mb' => array( + 'type' => 1, + ), + 'innodb_checksums' => array( + ), + 'innodb_commit_concurrency' => array( + ), + 'innodb_concurrency_tickets' => array( + 'type' => 2, + ), + 'innodb_doublewrite' => array( + ), + 'innodb_fast_shutdown' => array( + ), + 'innodb_file_io_threads' => array( + 'type' => 2, + ), + 'innodb_file_per_table' => array( + ), + 'innodb_flush_log_at_trx_commit' => array( + ), + 'innodb_flush_method' => array( + ), + 'innodb_force_recovery' => array( + ), + 'innodb_lock_wait_timeout' => array( + 'type' => 2, + ), + 'innodb_locks_unsafe_for_binlog' => array( + ), + 'innodb_log_arch_dir' => array( + ), + 'innodb_log_archive' => array( + ), + 'innodb_log_buffer_size' => array( + 'type' => 1, + ), + 'innodb_log_file_size' => array( + 'type' => 1, + ), + 'innodb_log_files_in_group' => array( + 'type' => 2, + ), + 'innodb_log_group_home_dir' => array( + ), + 'innodb_max_dirty_pages_pct' => array( + 'type' => 2, + ), + 'innodb_max_purge_lag' => array( + ), + 'innodb_mirrored_log_groups' => array( + 'type' => 2, + ), + 'innodb_open_files' => array( + 'type' => 2, + ), + 'innodb_support_xa' => array( + ), + 'innodb_sync_spin_loops' => array( + 'type' => 2, + ), + 'innodb_table_locks' => array( + 'type' => 3, + ), + 'innodb_thread_concurrency' => array( + 'type' => 2, + ), + 'innodb_thread_sleep_delay' => array( + 'type' => 2, + ), + ) + ); + } + + /** + * Test for getVariablesLikePattern + */ + public function testGetVariablesLikePattern(){ + $this->assertEquals( + $this->object->getVariablesLikePattern(), + 'innodb\\_%' + ); + } + + /** + * Test for getInfoPages + */ + public function testGetInfoPages(){ + $this->assertEquals( + $this->object->getInfoPages(), + array() + ); + $this->object->support = 2; + $this->assertEquals( + $this->object->getInfoPages(), + array ( + 'Bufferpool' => 'Buffer Pool', + 'Status' => 'InnoDB Status' + ) + ); + } + + /** + * Test for getPageBufferpool + */ + public function testGetPageBufferpool(){ + $this->assertEquals( + $this->object->getPageBufferpool(), + ' + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Buffer Pool Usage +
+ Total + : 10 pages / 40 B +
Free pages4
Dirty pages3
Pages containing data2 +
Pages to be flushed5 +
Busy pages1 +
Latched pages 2
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Buffer Pool Activity +
Read requests3 +
Write requests4 +
Read misses4 +
Write waits3 +
Read misses in %133.33 % +
Write waits in %75 % +
+' + + ); + } + + /** + * Test for getPageStatus + */ + public function testGetPageStatus(){ + if (! function_exists('PMA_DBI_fetch_value')) { + function PMA_DBI_fetch_value() + { + return 'status'; + } + } + + $this->assertEquals( + $this->object->getPageStatus(), + '
' . "\n"
+                . 'status' . "\n"
+                . '
' . "\n" + ); + + } + + /** + * Test for getPage + */ + public function testGetPage(){ + $this->assertFalse( + $this->object->getPage('Status') + ); + $this->object->support = 2; + $this->assertEquals( + $this->object->getPage('Status'), + '
' . "\n"
+                . 'status' . "\n"
+                . '
' . "\n" + ); + } + + /** + * Test for getMysqlHelpPage + */ + public function testGetMysqlHelpPage(){ + $this->assertEquals( + $this->object->getMysqlHelpPage(), + 'innodb' + ); + + } + + /** + * Test for getInnodbPluginVersion + */ + public function testGetInnodbPluginVersion(){ + $this->assertEquals( + $this->object->getInnodbPluginVersion(), + 'status' + ); + + } + + /** + * Test for supportsFilePerTable + */ + public function testSupportsFilePerTable(){ + $this->assertEquals( + $this->object->supportsFilePerTable(), + false + ); + + } + + /** + * Test for getInnodbFileFormat + */ + public function testGetInnodbFileFormat(){ + $this->assertEquals( + $this->object->getInnodbFileFormat(), + 'status' + ); + + } +}