Skip to content

Commit

Permalink
- Unit Test grouped by library directory
Browse files Browse the repository at this point in the history
 - Added configuration file phpunit.xml.dist and bootstraper-dist.php
 - Ignoring phpunit.xml, bootstraper.php and build/
  • Loading branch information
zarubin committed Jun 29, 2011
1 parent eb8caa4 commit f7d7102
Show file tree
Hide file tree
Showing 45 changed files with 1,195 additions and 543 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -20,6 +20,7 @@ phpmyadmin.wpj
.buildpath .buildpath
.cache .cache
.idea .idea
.netbeans
*.sw[op] *.sw[op]
# Locales # Locales
/locale/ /locale/
Expand All @@ -31,3 +32,8 @@ phpmyadmin.wpj
/apidoc/ /apidoc/
# Demo server # Demo server
revision-info.php revision-info.php
# PHPUnit
phpunit.xml
/test/bootstrap.php
# Jenkins
/build/
5 changes: 3 additions & 2 deletions libraries/core.lib.php
Expand Up @@ -224,8 +224,9 @@ function PMA_fatalError($error_message, $message_args = null)
} }


require('./libraries/error.inc.php'); require('./libraries/error.inc.php');


exit; if (!defined('TESTSUITE'))
exit;
} }


/** /**
Expand Down
36 changes: 36 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="test/bootstrap-dist.php"
backupGlobals="false"
backupStaticAttributes="false"
strict="true"
verbose="true">

<selenium>
<browser name="Firefox on localhost"
browser="*firefox"
host="127.0.0.1"
port="4444"
timeout="30000"/>
</selenium>

<testsuites>
<testsuite name="Unit">
<directory suffix="_test.php">test/libraries/core</directory>
<directory suffix="_test.php">test/libraries/common</directory>
<directory suffix="_test.php">test/libraries</directory>
<file>test/Environment_test.php</file>
</testsuite>
<testsuite name="Selenium">
<directory suffix="Test.php">test/selenium</directory>
</testsuite>
</testsuites>

<logging>
<log type="coverage-html" target="build/coverage" title="phpMyAdmin"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>

</phpunit>
49 changes: 43 additions & 6 deletions test/Environment_test.php
Expand Up @@ -9,7 +9,7 @@
/** /**
* *
*/ */
require_once 'PHPUnit/Framework.php'; require_once 'config.sample.inc.php';


/** /**
* @package phpMyAdmin-test * @package phpMyAdmin-test
Expand All @@ -24,12 +24,49 @@ public function testPhpVersion()


public function testMySQL() public function testMySQL()
{ {
$this->markTestIncomplete(); global $cfg;
}


public function testSession() foreach($cfg['Servers'] as $i=>$server){
{ // Check config for the server
$this->markTestIncomplete(); if (!isset($server["host"])){
$this->fail("Couldn't determine the host. Please check configuration for the server id: $i");
}
if (!isset($server["pmadb"])){
$this->markTestSkipped(); // If DB is not specified there is no reason to check connect.
}
elseif(!isset($server["controluser"])){
$this->fail("Please specify user for server $i and database ".$server["pmadb"]);
}

try{
if (!isset($server["controlpass"])){
$pdo = new PDO("mysql:host=".$server["host"].";dbname=".$server["pmadb"], $server['controluser']);
}
else{
$pdo = new PDO("mysql:host=".$server["host"].";dbname=".$server["pmadb"], $server['controluser'], $server['controlpass']);
}

$this->assertNull($pdo->errorCode());

//$pdo->beginTransaction();
$test = $pdo->exec("SHOW TABLES;");
//$pdo->commit();
$this->assertEquals(0, $pdo->errorCode());
}
catch (Exception $e){
$this->fail("Error: ".$e->getMessage());
}

// Check id MySQL server is 5 version
preg_match("/^(\d+)?\.(\d+)?\.(\*|\d+)/", $pdo->getAttribute(constant("PDO::ATTR_SERVER_VERSION")), $version_parts);
$this->assertEquals(5, $version_parts[1]);
}
} }

//TODO: Think about this test
// public function testSession()
// {
// $this->markTestIncomplete();
// }
} }
?> ?>
24 changes: 0 additions & 24 deletions test/FailTest.php

This file was deleted.

57 changes: 0 additions & 57 deletions test/PMA_escapeJsString_test.php

This file was deleted.

114 changes: 0 additions & 114 deletions test/PMA_isValid_test.php

This file was deleted.

14 changes: 3 additions & 11 deletions test/PMA_showHint_test.php
@@ -1,26 +1,17 @@
<?php <?php
/* vim: set expandtab sw=4 ts=4 sts=4: */ /* vim: set expandtab sw=4 ts=4 sts=4: */
/** /**
* Test for showHint function * Test for PMA_showHint() function from common.lib.php
* *
* @package phpMyAdmin-test * @package phpMyAdmin-test
* @version $Id: PMA_showHint_test.php * @version $Id: PMA_showHint_test.php
*/ */


/**
* Tests core.
*/
require_once 'PHPUnit/Framework.php';

/** /**
* Include to test. * Include to test.
*/ */
require_once './libraries/common.lib.php'; require_once 'libraries/common.lib.php';


/**
* Test showHint function.
*
*/
class PMA_showHint_test extends PHPUnit_Framework_TestCase class PMA_showHint_test extends PHPUnit_Framework_TestCase
{ {


Expand Down Expand Up @@ -105,6 +96,7 @@ public function testShowHintSetting()


/** /**
* PMA_showHint with not defined GLOBALS formatted as BB * PMA_showHint with not defined GLOBALS formatted as BB
* @depends testShowHintSetting
*/ */
public function testShowHintSettingBbFormat() public function testShowHintSettingBbFormat()
{ {
Expand Down
20 changes: 0 additions & 20 deletions test/PmaSeleniumLoginTest.php

This file was deleted.

12 changes: 12 additions & 0 deletions test/bootstrap-dist.php
@@ -0,0 +1,12 @@
<?php

// Adding phpMyAdmin sources to include path
set_include_path(get_include_path().PATH_SEPARATOR.dirname(realpath("../index.php")));

// Setting constants for testing
define('PHPMYADMIN', 1);
define('TESTSUITE', 1);

// You can put some additional code that runs before tests here

?>

0 comments on commit f7d7102

Please sign in to comment.