Skip to content
This repository was archived by the owner on Nov 26, 2017. It is now read-only.

Commit b6db641

Browse files
committed
Moving the legacy tests into their own suite.
1 parent d26a419 commit b6db641

37 files changed

+298
-178
lines changed

build.xml

+98-102
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,114 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<project name="joomla-platform" default="build" basedir=".">
4-
<property name="source" value="libraries"/>
5-
<property name="joomlasource" value="libraries/joomla,libraries/platform.php,libraries/loader.php,libraries/import.php"/>
4+
<property name="source" value="libraries" />
5+
<property name="joomlasource" value="libraries/joomla,libraries/platform.php,libraries/loader.php,libraries/import.php" />
66

7-
<target name="clean"
8-
description="Clean up and create artifact directories">
9-
<delete dir="${basedir}/build/api"/>
10-
<delete dir="${basedir}/build/code-browser"/>
11-
<delete dir="${basedir}/build/coverage"/>
12-
<delete dir="${basedir}/build/logs"/>
13-
<delete dir="${basedir}/build/pdepend"/>
7+
<target name="clean" description="Clean up and create artifact directories">
8+
<delete dir="${basedir}/build/api" />
9+
<delete dir="${basedir}/build/code-browser" />
10+
<delete dir="${basedir}/build/coverage" />
11+
<delete dir="${basedir}/build/logs" />
12+
<delete dir="${basedir}/build/pdepend" />
1413

15-
<mkdir dir="${basedir}/build/api"/>
16-
<mkdir dir="${basedir}/build/code-browser"/>
17-
<mkdir dir="${basedir}/build/coverage"/>
18-
<mkdir dir="${basedir}/build/logs"/>
19-
<mkdir dir="${basedir}/build/pdepend"/>
20-
</target>
14+
<mkdir dir="${basedir}/build/api" />
15+
<mkdir dir="${basedir}/build/code-browser" />
16+
<mkdir dir="${basedir}/build/coverage" />
17+
<mkdir dir="${basedir}/build/logs" />
18+
<mkdir dir="${basedir}/build/pdepend" />
19+
</target>
2120

22-
<target name="phpunit"
23-
description="Run unit tests using PHPUnit and generates junit.xml and clover.xml">
24-
<exec executable="phpunit"/>
25-
</target>
21+
<target name="phpunit" description="Run unit tests using PHPUnit and generates junit.xml and clover.xml">
22+
<exec executable="phpunit" />
23+
</target>
2624

27-
<target name="parallelTasks"
28-
description="Run the pdepend, phpmd, phpcpd, phpcs, phpdoc and phploc tasks in parallel using a maximum of 2 threads.">
29-
<parallel threadCount="2">
30-
<sequential>
31-
<antcall target="pdepend"/>
32-
<antcall target="phpmd"/>
33-
</sequential>
34-
<antcall target="phpcpd"/>
35-
<antcall target="phpcs"/>
36-
<antcall target="phpdoc"/>
37-
<antcall target="phploc"/>
38-
</parallel>
39-
</target>
25+
<target name="phpunit-legacy" description="Run legacy tests using PHPUnit and generates junit.legacy.xml and clover.legacy.xml">
26+
<exec executable="phpunit">
27+
<arg value="-c legacy.xml.dist" />
28+
</exec>
29+
</target>
4030

41-
<target name="pdepend"
42-
description="Generate jdepend.xml and software metrics charts using PHP_Depend">
43-
<exec executable="pdepend">
44-
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
45-
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
46-
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
47-
<arg path="${source}" />
48-
</exec>
49-
</target>
31+
<target name="parallelTasks" description="Run the pdepend, phpmd, phpcpd, phpcs, phpdoc and phploc tasks in parallel using a maximum of 2 threads.">
32+
<parallel threadCount="2">
33+
<sequential>
34+
<antcall target="pdepend" />
35+
<antcall target="phpmd" />
36+
</sequential>
37+
<antcall target="phpcpd" />
38+
<antcall target="phpcs" />
39+
<antcall target="phpdoc" />
40+
<antcall target="phploc" />
41+
</parallel>
42+
</target>
5043

51-
<target name="phpmd"
52-
description="Generate pmd.xml using PHPMD">
53-
<exec executable="phpmd">
54-
<arg path="${joomlasource}" />
55-
<arg value="xml" />
56-
<arg value="${basedir}/build/phpmd.xml" />
57-
<arg value="--reportfile" />
58-
<arg value="${basedir}/build/logs/pmd.xml" />
59-
</exec>
60-
</target>
44+
<target name="pdepend" description="Generate jdepend.xml and software metrics charts using PHP_Depend">
45+
<exec executable="pdepend">
46+
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
47+
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
48+
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
49+
<arg path="${source}" />
50+
</exec>
51+
</target>
6152

62-
<target name="phpcpd"
63-
description="Generate pmd-cpd.xml using PHPCPD">
64-
<exec executable="phpcpd">
65-
<arg value="--log-pmd" />
66-
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
67-
<arg path="${source}/joomla" />
68-
</exec>
69-
</target>
53+
<target name="phpmd" description="Generate pmd.xml using PHPMD">
54+
<exec executable="phpmd">
55+
<arg path="${joomlasource}" />
56+
<arg value="xml" />
57+
<arg value="${basedir}/build/phpmd.xml" />
58+
<arg value="--reportfile" />
59+
<arg value="${basedir}/build/logs/pmd.xml" />
60+
</exec>
61+
</target>
7062

71-
<target name="phploc"
72-
description="Generate phploc.csv">
73-
<exec executable="phploc">
74-
<arg value="--log-csv" />
75-
<arg value="${basedir}/build/logs/phploc.csv" />
76-
<arg path="${source}/joomla" />
77-
</exec>
78-
</target>
63+
<target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD">
64+
<exec executable="phpcpd">
65+
<arg value="--log-pmd" />
66+
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
67+
<arg path="${source}/joomla" />
68+
</exec>
69+
</target>
7970

80-
<target name="phpcs"
81-
description="Generate checkstyle.xml using PHP_CodeSniffer">
82-
<exec executable="phpcs">
83-
<arg value="--report=checkstyle" />
84-
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
85-
<arg value="--standard=${basedir}/build/phpcs/Joomla" />
86-
<arg value="--ignore=${source}/phpmailer,${source}/phputf8,${source}/simplepie/,${source}/config.example.php" />
87-
<arg path="${source}" />
88-
</exec>
89-
</target>
71+
<target name="phploc" description="Generate phploc.csv">
72+
<exec executable="phploc">
73+
<arg value="--log-csv" />
74+
<arg value="${basedir}/build/logs/phploc.csv" />
75+
<arg path="${source}/joomla" />
76+
</exec>
77+
</target>
9078

91-
<target name="phpdoc"
92-
description="Generate API documentation using PHPDocumentor">
93-
<exec executable="phpdox">
94-
<arg value="-c" />
95-
<arg path="${source}" />
96-
<arg value="-d" />
97-
<arg path="${basedir}/build/api" />
98-
<arg value="-x" />
99-
<arg path="${basedir}/build/docs" />
100-
<arg value="-g" />
101-
<arg value="html" />
102-
</exec>
103-
</target>
79+
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer">
80+
<exec executable="phpcs">
81+
<arg value="--report=checkstyle" />
82+
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
83+
<arg value="--standard=${basedir}/build/phpcs/Joomla" />
84+
<arg value="--ignore=${source}/phpmailer,${source}/phputf8,${source}/simplepie/,${source}/config.example.php" />
85+
<arg path="${source}" />
86+
</exec>
87+
</target>
10488

105-
<target name="phpcb"
106-
description="Aggregate tool output with PHP_CodeBrowser">
107-
<exec executable="phpcb">
108-
<arg value="--log" />
109-
<arg path="${basedir}/build/logs" />
110-
<arg value="--source" />
111-
<arg path="${source}" />
112-
<arg value="--output" />
113-
<arg path="${basedir}/build/code-browser" />
114-
</exec>
115-
</target>
89+
<target name="phpdoc" description="Generate API documentation using PHPDocumentor">
90+
<exec executable="phpdox">
91+
<arg value="-c" />
92+
<arg path="${source}" />
93+
<arg value="-d" />
94+
<arg path="${basedir}/build/api" />
95+
<arg value="-x" />
96+
<arg path="${basedir}/build/docs" />
97+
<arg value="-g" />
98+
<arg value="html" />
99+
</exec>
100+
</target>
116101

117-
<target name="build" depends="clean,parallelTasks,phpunit,phpcb"/>
102+
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
103+
<exec executable="phpcb">
104+
<arg value="--log" />
105+
<arg path="${basedir}/build/logs" />
106+
<arg value="--source" />
107+
<arg path="${source}" />
108+
<arg value="--output" />
109+
<arg path="${basedir}/build/code-browser" />
110+
</exec>
111+
</target>
112+
113+
<target name="build" depends="clean,phpunit,phpunit-legacy,parallelTasks,phpcb" />
118114
</project>

legacy.xml.dist

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="tests/bootstrap.legacy.php" colors="false">
3+
<!-- These constants help setup environment configurations for running optional tests.
4+
<php>
5+
<const name="JTEST_DATABASE_MYSQL_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
6+
<const name="JTEST_DATABASE_MYSQLI_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
7+
<const name="JTEST_DATABASE_POSTGRESQL_DSN" value="host=localhost;port=5432;dbname=joomla_ut;user=utuser;pass=ut1234" />
8+
<const name="JTEST_HTTP_STUB" value="http://localhost/joomla-platform/tests/suites/unit/stubs/jhttp_stub.php" />
9+
</php>
10+
-->
11+
12+
<testsuites>
13+
<testsuite name="Legacy">
14+
<directory>tests/suites/legacy</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<logging>
19+
<log type="coverage-html" target="build/coverage-legacy" title="Joomla-Platform-Legacy" charset="UTF-8" yui="true" highlight="true"
20+
lowUpperBound="35" highLowerBound="70" />
21+
<log type="coverage-clover" target="build/logs/clover.legacy.xml" />
22+
<log type="junit" target="build/logs/junit.legacy.xml" logIncompleteSkipped="false" />
23+
</logging>
24+
<filter>
25+
<whitelist addUncoveredFilesFromWhitelist="false">
26+
<directory suffix=".php">libraries/legacy</directory>
27+
</whitelist>
28+
</filter>
29+
</phpunit>

phpunit.xml.dist

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<phpunit bootstrap="tests/bootstrap.php" colors="false">
4-
5-
<!-- <php>
3+
<!-- These constants help setup environment configurations for running optional tests.
4+
<php>
65
<const name="JTEST_DATABASE_MYSQL_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
76
<const name="JTEST_DATABASE_MYSQLI_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
87
<const name="JTEST_DATABASE_POSTGRESQL_DSN" value="host=localhost;port=5432;dbname=joomla_ut;user=utuser;pass=ut1234" />
98
<const name="JTEST_HTTP_STUB" value="http://localhost/joomla-platform/tests/suites/unit/stubs/jhttp_stub.php" />
10-
</php> -->
9+
</php>
10+
-->
1111

12-
<testsuite name="AllTests">
13-
<directory>tests/suites</directory>
14-
</testsuite>
12+
<testsuites>
13+
<testsuite name="Database">
14+
<directory>tests/suites/database</directory>
15+
</testsuite>
16+
<testsuite name="Unit">
17+
<directory>tests/suites/unit</directory>
18+
</testsuite>
19+
</testsuites>
1520

1621
<logging>
17-
<log type="coverage-html" target="build/coverage" title="Joomla-Platform"
18-
charset="UTF-8" yui="true" highlight="true" lowUpperBound="35"
19-
highLowerBound="70" />
22+
<log type="coverage-html" target="build/coverage" title="Joomla-Platform" charset="UTF-8" yui="true" highlight="true"
23+
lowUpperBound="35" highLowerBound="70" />
2024
<log type="coverage-clover" target="build/logs/clover.xml" />
21-
<log type="junit" target="build/logs/junit.xml"
22-
logIncompleteSkipped="false" />
25+
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false" />
2326
</logging>
2427
<filter>
25-
<whitelist addUncoveredFilesFromWhitelist="false">
28+
<whitelist addUncoveredFilesFromWhitelist="true">
2629
<directory suffix=".php">libraries/joomla</directory>
27-
<directory suffix=".php">libraries/legacy</directory>
2830
<file>libraries/import.php</file>
2931
<file>libraries/loader.php</file>
3032
<file>libraries/platform.php</file>

tests/bootstrap.legacy.php

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Prepares a minimalist framework for unit testing.
4+
*
5+
* Joomla is assumed to include the /unittest/ directory.
6+
* eg, /path/to/joomla/unittest/
7+
*
8+
* @package Joomla.UnitTest
9+
*
10+
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
11+
* @license GNU General Public License version 2 or later; see LICENSE
12+
* @link http://www.phpunit.de/manual/current/en/installation.html
13+
*/
14+
15+
define('_JEXEC', 1);
16+
17+
// Fix magic quotes.
18+
@ini_set('magic_quotes_runtime', 0);
19+
20+
// Maximise error reporting.
21+
@ini_set('zend.ze1_compatibility_mode', '0');
22+
error_reporting(E_ALL);
23+
ini_set('display_errors', 1);
24+
25+
/*
26+
* Ensure that required path constants are defined. These can be overridden within the phpunit.xml file
27+
* if you chose to create a custom version of that file.
28+
*/
29+
if (!defined('JPATH_TESTS'))
30+
{
31+
define('JPATH_TESTS', realpath(__DIR__));
32+
}
33+
if (!defined('JPATH_PLATFORM'))
34+
{
35+
define('JPATH_PLATFORM', realpath(dirname(JPATH_TESTS) . '/libraries'));
36+
}
37+
if (!defined('JPATH_BASE'))
38+
{
39+
define('JPATH_BASE', realpath(JPATH_TESTS . '/tmp'));
40+
}
41+
if (!defined('JPATH_ROOT'))
42+
{
43+
define('JPATH_ROOT', realpath(JPATH_BASE));
44+
}
45+
if (!defined('JPATH_CACHE'))
46+
{
47+
define('JPATH_CACHE', JPATH_BASE . '/cache');
48+
}
49+
if (!defined('JPATH_CONFIGURATION'))
50+
{
51+
define('JPATH_CONFIGURATION', JPATH_BASE);
52+
}
53+
if (!defined('JPATH_MANIFESTS'))
54+
{
55+
define('JPATH_MANIFESTS', JPATH_BASE . '/manifests');
56+
}
57+
if (!defined('JPATH_PLUGINS'))
58+
{
59+
define('JPATH_PLUGINS', JPATH_BASE . '/plugins');
60+
}
61+
if (!defined('JPATH_THEMES'))
62+
{
63+
define('JPATH_THEMES', JPATH_BASE . '/themes');
64+
}
65+
66+
// Import the platform.
67+
require_once JPATH_PLATFORM . '/import.legacy.php';
68+
69+
// Register the core Joomla test classes.
70+
JLoader::registerPrefix('Test', __DIR__ . '/core');

tests/bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
}
6565

6666
// Import the platform.
67-
require_once JPATH_PLATFORM . '/import.legacy.php';
67+
require_once JPATH_PLATFORM . '/import.php';
6868

6969
// Register the core Joomla test classes.
7070
JLoader::registerPrefix('Test', __DIR__ . '/core');

0 commit comments

Comments
 (0)