Add UT to validate that the data is set correctly on the sub class of Schema #490

Merged
merged 4 commits into from Jul 10, 2013

Projects

None yet

2 participants

@adamgsoc2013
Contributor

fix the class redefine error in sub class of Schema …

  1. change class Table_Stats to Table_Stats_$type
  2. change class Relation_Stats to Relation_Stats_$type
@adamgsoc2013 adamgsoc2013 commented on the diff Jul 10, 2013
libraries/schema/Dia_Relation_Schema.class.php
* @see PMA_DIA
*/
-class Table_Stats
+class Table_Stats_Dia
@adamgsoc2013
adamgsoc2013 Jul 10, 2013 Contributor

all sub schema classes defines Table_Stats and Relation_Stats, that will cause redefine error when running UT

@adamgsoc2013 adamgsoc2013 and 1 other commented on an outdated diff Jul 10, 2013
libraries/schema/Dia_Relation_Schema.class.php
@@ -762,8 +762,12 @@ function __construct()
$this->_drawRelations($this->showColor);
}
$dia->endDiaDoc();
- $dia->showOutput($db . '-' . $this->pageNumber);
- exit();
+
+ //IF in UT, we can't output and exit
+ if (!defined('TESTSUITE')) {
@adamgsoc2013
adamgsoc2013 Jul 10, 2013 Contributor

the two statements will cause UT exit and failed

@nijel
nijel Jul 10, 2013 Member

I think this code is not really behaving as expected - constructor should not output and exit anyway. Workarounding it for testsuite is an option, but I'd really prefer to have separate methods for generating output and no exit statement used here (if necessary, it should be done in calling code).

@adamgsoc2013
Contributor

Hi Michal, I have fixed the issues you mentioned:

  1. split "output" function from constructor for Schema classes, and call it when the schema class is constructed outside.
  2. remove "exit" which is unneeded action

I have tested the new code, it is working as before. thanks

@nijel

You should not use globals here, store needed parameters as attributes of the class.

@nijel nijel merged commit 959f94f into phpmyadmin:master Jul 10, 2013

1 check passed

default The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment