Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Refactor the DBI mocking for Pdf_Relation_Schema_test #590

Merged
merged 1 commit into from

2 participants

@adamgsoc2013

No description provided.

@nijel nijel merged commit 0176085 into phpmyadmin:master

1 check failed

Details default The Travis CI build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 12, 2013
  1. @adamgsoc2013
This page is out of date. Refresh to see the latest.
Showing with 37 additions and 7 deletions.
  1. +37 −7 test/classes/schema/Pdf_Relation_Schema_test.php
View
44 test/classes/schema/Pdf_Relation_Schema_test.php
@@ -16,6 +16,7 @@
require_once 'libraries/Index.class.php';
require_once 'libraries/Table.class.php';
require_once 'libraries/database_interface.inc.php';
+require_once 'libraries/transformations.lib.php';
require_once 'libraries/schema/Pdf_Relation_Schema.class.php';
/**
@@ -51,6 +52,8 @@ protected function setUp()
$_POST['with_doc'] = 'on';
$GLOBALS['server'] = 1;
+ $GLOBALS['controllink'] = null;
+ $GLOBALS['db'] = 'information_schema';
$GLOBALS['cfg']['Server']['pmadb'] = "pmadb";
$GLOBALS['cfg']['LimitChars'] = 100;
$GLOBALS['cfg']['ServerDefault'] = 1;
@@ -58,11 +61,20 @@ protected function setUp()
$GLOBALS['cfg']['Server']['table_coords'] = "table_name";
$GLOBALS['cfg']['Server']['bookmarktable'] = "bookmarktable";
$GLOBALS['cfg']['Server']['relation'] = "relation";
- $GLOBALS['cfg']['Server']['relation'] = "relation";
$GLOBALS['cfg']['Server']['table_info'] = "table_info";
-
- $GLOBALS['cfgRelation']['db'] = "PMA";
- $GLOBALS['cfgRelation']['table_coords'] = "table_name";
+
+ //_SESSION
+ $_SESSION['relation'][$GLOBALS['server']] = array(
+ 'table_coords' => "table_name",
+ 'displaywork' => 'displaywork',
+ 'db' => "information_schema",
+ 'table_info' => 'table_info',
+ 'relwork' => false,
+ 'relation' => 'relation',
+ 'mimework' => 'mimework',
+ 'commwork' => 'commwork',
+ 'column_info' => 'column_info'
+ );
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
@@ -79,9 +91,15 @@ protected function setUp()
$dbi->expects($this->any())
->method('tryQuery')
->will($this->returnValue("executed_1"));
-
+
$fetchArrayReturn = array(
- 'table_name' => 'pma_table_name'
+ //table name in information_schema_relations
+ 'table_name' => 'CHARACTER_SETS'
+ );
+
+ $fetchArrayReturn2 = array(
+ //table name in information_schema_relations
+ 'table_name' => 'COLLATIONS'
);
$dbi->expects($this->at(2))
@@ -89,6 +107,9 @@ protected function setUp()
->will($this->returnValue($fetchArrayReturn));
$dbi->expects($this->at(3))
->method('fetchAssoc')
+ ->will($this->returnValue($fetchArrayReturn2));
+ $dbi->expects($this->at(4))
+ ->method('fetchAssoc')
->will($this->returnValue(false));
$fetchRowReturn = array(
@@ -142,10 +163,19 @@ protected function setUp()
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 "
. "COLLATE=utf8_bin COMMENT='Bookmarks'";
- $dbi->expects($this->once())
+ $dbi->expects($this->any())
->method('fetchValue')
->will($this->returnValue($fetchValue));
+
+ $fetchResult = array(
+ 'column1' => array('mimetype' => 'value1', 'transformation'=> 'pdf'),
+ 'column2' => array('mimetype' => 'value2', 'transformation'=> 'xml'),
+ );
+
+ $dbi->expects($this->any())->method('fetchResult')
+ ->will($this->returnValue($fetchResult));
+
$GLOBALS['dbi'] = $dbi;
$this->object = new PMA_Pdf_Relation_Schema();
Something went wrong with that request. Please try again.