mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
merging changes to tests from my sandbox
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@789 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6019c0d98d
commit
731cc517e9
14 changed files with 2113 additions and 143 deletions
|
@ -1306,7 +1306,10 @@ class Model extends Object
|
|||
|
||||
$merged = array_merge_recursive($data[$count],$oneToManySelect1);
|
||||
$newdata[$count] = $merged;
|
||||
unset( $oneToManySelect[$table] );
|
||||
//added fix from Ticket #188
|
||||
//I had this in code before and removed
|
||||
// If this cause problems may need to look into it more -PhpNut
|
||||
unset( $oneToManySelect[$table], $oneToManySelect1);
|
||||
}
|
||||
|
||||
if(!empty($newdata[$count]))
|
||||
|
|
110
public/test/rss2html.xsl
Normal file
110
public/test/rss2html.xsl
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!--
|
||||
@(#) $Id$
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rss="http://purl.org/rss/1.0/" xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<xsl:output method="html"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
||||
<style type="text/css">
|
||||
div.channel-title { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.image { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.image-description { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.item-title { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.item-description { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.textinput-title { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.textinput-form { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<title>
|
||||
<xsl:for-each select="rdf:RDF/rss:channel">
|
||||
<xsl:value-of select="rss:description"/>
|
||||
</xsl:for-each>
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<xsl:for-each select="rdf:RDF/rss:image">
|
||||
<center><div class="image">
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:element name="img">
|
||||
<xsl:attribute name="src"><xsl:value-of select="rss:url"/></xsl:attribute>
|
||||
<xsl:attribute name="alt"><xsl:value-of select="rss:title"/></xsl:attribute>
|
||||
<xsl:attribute name="border">0</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</div></center>
|
||||
<center><div class="image-description">
|
||||
<xsl:value-of select="rss:description"/>
|
||||
</div></center>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:for-each select="rdf:RDF/rss:channel">
|
||||
<center><div class="channel-title">
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:value-of select="rss:title"/>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="dc:date"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
</xsl:element>
|
||||
</div></center>
|
||||
</xsl:for-each>
|
||||
|
||||
<ul>
|
||||
<hr />
|
||||
<xsl:for-each select="rdf:RDF/rss:item">
|
||||
<div class="item-title"><li>
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:value-of select="rss:title"/>
|
||||
</xsl:element>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="dc:date"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
</li></div>
|
||||
<div class="item-description"><xsl:value-of select="rss:description"/></div>
|
||||
<hr />
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
|
||||
<xsl:for-each select="rdf:RDF/rss:textinput">
|
||||
<center><b><div class="textinput-title"><xsl:value-of select="rss:description"/></div></b></center>
|
||||
<xsl:element name="form">
|
||||
<xsl:attribute name="action"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:attribute name="method">POST</xsl:attribute>
|
||||
<center><div class="textinput-form">
|
||||
<xsl:element name="input">
|
||||
<xsl:attribute name="name"><xsl:value-of select="rss:name"/></xsl:attribute>
|
||||
<xsl:attribute name="type">text</xsl:attribute>
|
||||
</xsl:element>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:element name="input">
|
||||
<xsl:attribute name="value"><xsl:value-of select="rss:title"/></xsl:attribute>
|
||||
<xsl:attribute name="type">submit</xsl:attribute>
|
||||
</xsl:element>
|
||||
</div></center>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
37
tests/config.ini.php
Normal file
37
tests/config.ini.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
;<?php die() ?>
|
||||
; SVN FILE: $Id$
|
||||
;/**
|
||||
; * Short description for file.
|
||||
; *
|
||||
; * Long description for file
|
||||
; *
|
||||
; * PHP versions 4 and 5
|
||||
; *
|
||||
; * CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
; * Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
; * Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
||||
; *
|
||||
; * Portions modified from WACT Test Suite <http://www.phpwact.org>
|
||||
; * Author(s): Harry Fuecks
|
||||
; * Jon Ramsey
|
||||
; * Jason E. Sweat
|
||||
; * Franco Ponticelli
|
||||
; * Lorenzo Alberton
|
||||
; *
|
||||
; * Licensed under The Open Group Test Suite License
|
||||
; * Redistributions of files must retain the above copyright notice.
|
||||
; *
|
||||
; * @filesource
|
||||
; * @author CakePHP Test Suite Authors/Developers
|
||||
; * @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
; * @link https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/Authors Authors/Developers
|
||||
; * @package tests
|
||||
; * @since CakePHP Test Suite v 1.0.0.0
|
||||
; * @version $Revision$
|
||||
; * @modifiedby $LastChangedBy$
|
||||
; * @lastmodified $Date$
|
||||
; * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
; */
|
||||
|
||||
[output]
|
||||
TEST_OUTPUT = html
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
*
|
||||
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/TestSuite/Authors/ Authors/Developers
|
||||
* @package test_suite
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load Test Manager Class
|
||||
*/
|
||||
require_once TESTS .'suite_libs/TestManager.php';
|
||||
|
||||
/** AllButExamplesTest
|
||||
*
|
||||
* This test group will run all test in the cases
|
||||
* directory with the exception of examples in the
|
||||
* examples directory.
|
||||
*
|
||||
* @todo implement, nothing coded yet!!!
|
||||
*
|
||||
* @package test_suite
|
||||
* @subpackage test_suite.cases.app
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class AllButExamplesTest extends GroupTest
|
||||
{
|
||||
function AllButExamplesTest()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
286
tests/index.php
286
tests/index.php
|
@ -10,9 +10,14 @@
|
|||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
||||
*
|
||||
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||
* Portions modified from WACT Test Suite
|
||||
* Author(s): Harry Fuecks
|
||||
* Jon Ramsey
|
||||
* Jason E. Sweat
|
||||
* Franco Ponticelli
|
||||
* Lorenzo Alberton
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
|
@ -21,8 +26,7 @@
|
|||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/Authors Authors/Developers
|
||||
* @package test_suite
|
||||
* @subpackage test_suite.tests_1_x
|
||||
* @package tests
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
|
@ -46,15 +50,172 @@ ini_set('memory_limit','128M');
|
|||
define('ROOT', dirname(dirname(dirname(__FILE__))).DS);
|
||||
}
|
||||
|
||||
require_once ROOT . 'config/paths.php';
|
||||
require_once ROOT . 'config'.DS.'paths.php';
|
||||
require_once TESTS . 'test_paths.php';
|
||||
require_once TESTS . 'suite_libs'.DS.'test_manager.php';
|
||||
require_once SIMPLE_TEST . 'unit_tester.php';
|
||||
require_once SIMPLE_TEST . 'web_tester.php';
|
||||
require_once SIMPLE_TEST . 'mock_objects.php';
|
||||
require_once TESTS . 'lib'.DS.'test_manager.php';
|
||||
require_once SIMPLE_TEST . 'reporter.php';
|
||||
|
||||
if (!isset( $_SERVER['SERVER_NAME'] ))
|
||||
{
|
||||
$_SERVER['SERVER_NAME'] = '';
|
||||
}
|
||||
|
||||
if (empty( $_GET['output']))
|
||||
{
|
||||
TestManager::setOutputFromIni(TESTS . 'config.ini.php');
|
||||
$_GET['output'] = TEST_OUTPUT;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Used to determine output to display
|
||||
*/
|
||||
define('CAKE_TEST_OUTPUT_HTML',1);
|
||||
define('CAKE_TEST_OUTPUT_XML',2);
|
||||
define('CAKE_TEST_OUTPUT_TEXT',3);
|
||||
|
||||
if ( isset($_GET['output']) && $_GET['output'] == 'xml' )
|
||||
{
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_XML);
|
||||
}
|
||||
elseif ( isset($_GET['output']) && $_GET['output'] == 'html' )
|
||||
{
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
|
||||
}
|
||||
else
|
||||
{
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
|
||||
}
|
||||
|
||||
function & CakeTestsGetReporter()
|
||||
{
|
||||
static $Reporter = NULL;
|
||||
if ( !$Reporter )
|
||||
{
|
||||
switch ( CAKE_TEST_OUTPUT )
|
||||
{
|
||||
case CAKE_TEST_OUTPUT_XML:
|
||||
require_once SIMPLE_TEST . 'xml.php';
|
||||
$Reporter = new XmlReporter();
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
require_once TESTS . 'lib'.DS.'cake_reporter.php';
|
||||
$Reporter = new CakeHtmlReporter();
|
||||
break;
|
||||
|
||||
default:
|
||||
$Reporter = new TextReporter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $Reporter;
|
||||
}
|
||||
|
||||
function CakePHPTestRunMore()
|
||||
{
|
||||
switch ( CAKE_TEST_OUTPUT )
|
||||
{
|
||||
case CAKE_TEST_OUTPUT_XML:
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
echo "<p><a href='" . $_SERVER['PHP_SELF'] . "'>Run more tests</a></p>";
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestCaseList()
|
||||
{
|
||||
switch ( CAKE_TEST_OUTPUT )
|
||||
{
|
||||
case CAKE_TEST_OUTPUT_XML:
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
echo XmlTestManager::getTestCaseList(APP_TEST_CASES);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo XmlTestManager::getTestCaseList(CORE_TEST_CASES);
|
||||
}
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
echo HtmlTestManager::getTestCaseList(APP_TEST_CASES);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo HtmlTestManager::getTestCaseList(CORE_TEST_CASES);
|
||||
}
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
echo TextTestManager::getTestCaseList(APP_TEST_CASES);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo TextTestManager::getTestCaseList(CORE_TEST_CASES);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestGroupTestList()
|
||||
{
|
||||
switch ( CAKE_TEST_OUTPUT )
|
||||
{
|
||||
case CAKE_TEST_OUTPUT_XML:
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
echo XmlTestManager::getGroupTestList(APP_TEST_GROUPS);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo XmlTestManager::getGroupTestList(CORE_TEST_GROUPS);
|
||||
}
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
echo HtmlTestManager::getGroupTestList(APP_TEST_GROUPS);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo HtmlTestManager::getGroupTestList(CORE_TEST_GROUPS);
|
||||
}
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
echo TextTestManager::getGroupTestList(APP_TEST_GROUPS);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo TextTestManager::getGroupTestList(CORE_TEST_GROUPS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestHeader()
|
||||
{
|
||||
switch ( CAKE_TEST_OUTPUT )
|
||||
{
|
||||
case CAKE_TEST_OUTPUT_XML:
|
||||
header('Content-Type: text/xml; charset="utf-8"');
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$header = <<<EOF
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -66,15 +227,26 @@ ini_set('memory_limit','128M');
|
|||
<body>
|
||||
|
||||
EOF;
|
||||
echo $header;
|
||||
echo $header;
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
header('Content-type: text/plain');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestSuiteHeader()
|
||||
{
|
||||
$groups = class_exists('Object') ? 'groups' : $_SERVER['PHP_SELF'].'?show=groups';
|
||||
$cases = class_exists('Object') ? 'cases' : $_SERVER['PHP_SELF'].'?show=cases';
|
||||
|
||||
$suiteHeader = <<<EOD
|
||||
{
|
||||
switch ( CAKE_TEST_OUTPUT )
|
||||
{
|
||||
case CAKE_TEST_OUTPUT_XML:
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$groups = class_exists('Object') ? 'groups' : $_SERVER['PHP_SELF'].'?show=groups';
|
||||
$cases = class_exists('Object') ? 'cases' : $_SERVER['PHP_SELF'].'?show=cases';
|
||||
$suiteHeader = <<<EOD
|
||||
<div id="main">
|
||||
<div id="header">
|
||||
<div id="headerLogo"><img src="/img/logo.png" alt="" /></div>
|
||||
|
@ -82,29 +254,85 @@ echo $header;
|
|||
<h2>Test Suite v 1.0.0.0</h2>
|
||||
</div>
|
||||
</div>
|
||||
<p><a href='$groups'>Test Groups</a> || <a href='$cases'>Test Cases</a></p>
|
||||
<p><a href='$groups'>Core Test Groups</a> || <a href='$cases'>Core Test Cases</a></p>
|
||||
<p><a href='$groups&app=true'>App Test Groups</a> || <a href='$cases&app=true'>App Test Cases</a></p>
|
||||
EOD;
|
||||
echo $suiteHeader;
|
||||
echo $suiteHeader;
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function CakePHPTestSuiteFooter()
|
||||
{
|
||||
$footer = <<<EOD
|
||||
</body>
|
||||
</html>
|
||||
switch ( CAKE_TEST_OUTPUT )
|
||||
{
|
||||
case CAKE_TEST_OUTPUT_XML:
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$footer = <<<EOD
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
echo $footer;
|
||||
echo $footer;
|
||||
break;
|
||||
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['group']))
|
||||
{
|
||||
if ('all' == $_GET['group'])
|
||||
{
|
||||
TestManager::runAllTests(CakeTestsGetReporter());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']),
|
||||
APP_TEST_GROUPS,
|
||||
CakeTestsGetReporter());
|
||||
}
|
||||
else
|
||||
{
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']),
|
||||
CORE_TEST_GROUPS,
|
||||
CakeTestsGetReporter());
|
||||
}
|
||||
}
|
||||
|
||||
CakePHPTestRunMore();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['case']))
|
||||
{
|
||||
TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
|
||||
CakePHPTestRunMore();
|
||||
exit();
|
||||
}
|
||||
|
||||
CakePHPTestHeader();
|
||||
CakePHPTestSuiteHeader();
|
||||
|
||||
if (isset($_GET['cases']))
|
||||
{
|
||||
CakePHPTestCaseList();
|
||||
}
|
||||
elseif (isset($_GET['groups']))
|
||||
{
|
||||
CakePHPTestGroupTestList();
|
||||
}
|
||||
if (isset($_GET['show']) && $_GET['show'] == 'cases')
|
||||
{
|
||||
CakePHPTestCaseList();
|
||||
}
|
||||
else
|
||||
{
|
||||
CakePHPTestGroupTestList();
|
||||
}
|
||||
CakePHPTestSuiteFooter();
|
||||
|
||||
?>
|
86
tests/lib/cake_reporter.php
Normal file
86
tests/lib/cake_reporter.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/TestSuite/Authors/ Authors/Developers
|
||||
* @package tests
|
||||
* @subpackage tests.libs
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package tests
|
||||
* @subpackage tests.libs
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class CakeHtmlReporter extends HtmlReporter
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Does nothing yet. The first output will
|
||||
* be sent on the first test start. For use
|
||||
* by a web browser.
|
||||
* @access public
|
||||
*/
|
||||
function CakeHtmlReporter($character_set = 'ISO-8859-1')
|
||||
{
|
||||
parent::HtmlReporter($character_set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the top of the web page setting the
|
||||
* title to the name of the starting test.
|
||||
* @param string $test_name Name class of test.
|
||||
* @access public
|
||||
*/
|
||||
function paintHeader($test_name)
|
||||
{
|
||||
$this->sendNoCacheHeaders();
|
||||
print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
|
||||
print "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
|
||||
print "<head>\n";
|
||||
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" .
|
||||
$this->_character_set . "\">\n";
|
||||
print "<title>CakePHP Test Suite v 1.0.0.0 :: $test_name</title>\n";
|
||||
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/default.css\" />\n";
|
||||
print "<style type=\"text/css\">\n";
|
||||
print $this->_getCss() . "\n";
|
||||
print "</style>\n";
|
||||
print "</head>\n<body>\n";
|
||||
print "<div id=\"main\">\n";
|
||||
print "<div id=\"header\">\n";
|
||||
print "<div id=\"headerLogo\"><img src=\"/img/logo.png\" alt=\"\" /></div>\n";
|
||||
print "<div id=\"headerNav\">\n";
|
||||
print "<h2>Test Suite v 1.0.0.0</h2>\n";
|
||||
print "</div>\n";
|
||||
print "</div>\n";
|
||||
print "<h2>$test_name</h2>\n";
|
||||
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -10,9 +10,14 @@
|
|||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
||||
*
|
||||
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||
* Portions modified from WACT Test Suite <http://www.phpwact.org>
|
||||
* Author(s): Harry Fuecks
|
||||
* Jon Ramsey
|
||||
* Jason E. Sweat
|
||||
* Franco Ponticelli
|
||||
* Lorenzo Alberton
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
|
@ -21,8 +26,8 @@
|
|||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/TestSuite/Authors/ Authors/Developers
|
||||
* @package test_suite
|
||||
* @subpackage test_suite.suite_libs
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
|
@ -39,8 +44,8 @@ SimpleTestOptions::ignore('CakeWebTestCase');
|
|||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package test_suite
|
||||
* @subpackage test_suite.suite_libs
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class CakeWebTestCase extends WebTestCase {
|
127
tests/lib/cli_reporter.php
Normal file
127
tests/lib/cli_reporter.php
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
||||
*
|
||||
* Portions modified from WACT Test Suite <http://www.phpwact.org>
|
||||
* Author(s): Harry Fuecks
|
||||
* Jon Ramsey
|
||||
* Jason E. Sweat
|
||||
* Franco Ponticelli
|
||||
* Lorenzo Alberton
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/TestSuite/Authors/ Authors/Developers
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
|
||||
if (! defined('ST_FAILDETAIL_SEPARATOR')) {
|
||||
define('ST_FAILDETAIL_SEPARATOR', "->");
|
||||
}
|
||||
|
||||
if (! defined('ST_FAILS_RETURN_CODE')) {
|
||||
define('ST_FAILS_RETURN_CODE', 1);
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '4.3.0', '<') ||
|
||||
php_sapi_name() == 'cgi') {
|
||||
define('STDOUT', fopen('php://stdout', 'w'));
|
||||
define('STDERR', fopen('php://stderr', 'w'));
|
||||
register_shutdown_function(
|
||||
create_function('', 'fclose(STDOUT); fclose(STDERR); return true;'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimal command line test displayer. Writes fail details to STDERR. Returns 0
|
||||
* to the shell if all tests pass, ST_FAILS_RETURN_CODE if any test fails.
|
||||
*/
|
||||
class CLIReporter extends SimpleReporter {
|
||||
|
||||
var $faildetail_separator = ST_FAILDETAIL_SEPARATOR;
|
||||
|
||||
function CLIReporter($faildetail_separator = NULL) {
|
||||
$this->SimpleReporter();
|
||||
if (! is_null($faildetail_separator)) {
|
||||
$this->setFailDetailSeparator($faildetail_separator);
|
||||
}
|
||||
}
|
||||
|
||||
function setFailDetailSeparator($separator) {
|
||||
$this->faildetail_separator = $separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formatted faildetail for printing.
|
||||
*/
|
||||
function &_paintTestFailDetail(&$message) {
|
||||
$buffer = '';
|
||||
$faildetail = $this->getTestList();
|
||||
array_shift($faildetail);
|
||||
$buffer .= implode($this->faildetail_separator, $faildetail);
|
||||
$buffer .= $this->faildetail_separator . "$message\n";
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint fail faildetail to STDERR.
|
||||
*/
|
||||
function paintFail($message) {
|
||||
parent::paintFail($message);
|
||||
fwrite(STDERR, 'FAIL' . $this->faildetail_separator .
|
||||
$this->_paintTestFailDetail($message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint exception faildetail to STDERR.
|
||||
*/
|
||||
function paintException($message) {
|
||||
parent::paintException($message);
|
||||
fwrite(STDERR, 'EXCEPTION' . $this->faildetail_separator .
|
||||
$this->_paintTestFailDetail($message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint a footer with test case name, timestamp, counts of fails and
|
||||
* exceptions.
|
||||
*/
|
||||
function paintFooter($test_name) {
|
||||
$buffer = $this->getTestCaseProgress() . '/' .
|
||||
$this->getTestCaseCount() . ' test cases complete: ';
|
||||
|
||||
if (0 < ($this->getFailCount() + $this->getExceptionCount())) {
|
||||
$buffer .= $this->getPassCount() . " passes";
|
||||
if (0 < $this->getFailCount()) {
|
||||
$buffer .= ", " . $this->getFailCount() . " fails";
|
||||
}
|
||||
if (0 < $this->getExceptionCount()) {
|
||||
$buffer .= ", " . $this->getExceptionCount() . " exceptions";
|
||||
}
|
||||
$buffer .= ".\n";
|
||||
fwrite(STDOUT, $buffer);
|
||||
exit(ST_FAILS_RETURN_CODE);
|
||||
} else {
|
||||
fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
389
tests/lib/rss_writer_class.php
Normal file
389
tests/lib/rss_writer_class.php
Normal file
|
@ -0,0 +1,389 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id:*/
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* Copyright (c) Manuel Lemos 2001-2002
|
||||
*
|
||||
* Licensed under The BSD License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @author Manuel Lemos
|
||||
* @copyright Copyright (c) 2001-2002, Manuel Lemos
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/bsd-license.html BSD
|
||||
*/
|
||||
|
||||
if(!defined("METAL_LIBRARY_XML_RSS_WRITER_CLASS"))
|
||||
{
|
||||
define("METAL_LIBRARY_XML_RSS_WRITER_CLASS",1);
|
||||
|
||||
|
||||
class rss_writer_class extends xml_writer_class
|
||||
{
|
||||
/*
|
||||
* Protected variables
|
||||
*
|
||||
*/
|
||||
var $root="";
|
||||
var $channel="";
|
||||
var $image="";
|
||||
var $textinput="";
|
||||
var $items=0;
|
||||
var $itemsequence="";
|
||||
|
||||
/*
|
||||
* Public variables
|
||||
*
|
||||
*/
|
||||
var $specification="1.0";
|
||||
var $about="";
|
||||
var $rssnamespaces=array();
|
||||
var $allownoitems=0;
|
||||
var $generatedcomment="Generated by: http://www.phpclasses.org/rsswriter";
|
||||
|
||||
|
||||
/*
|
||||
* Protected functions
|
||||
*
|
||||
*/
|
||||
Function addrssproperties(&$properties,$parent,&$required,&$optional,$scope)
|
||||
{
|
||||
$noattributes=array();
|
||||
$required_properties=0;
|
||||
Reset($properties);
|
||||
$end=(GetType($property=Key($properties))!="string");
|
||||
for(;!$end;)
|
||||
{
|
||||
if(IsSet($required[$property]))
|
||||
{
|
||||
if($required[$property])
|
||||
{
|
||||
$this->error=("required ".$scope." property \"".$property."\" is already set");
|
||||
return 0;
|
||||
}
|
||||
$required[$property]=1;
|
||||
$required_properties++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IsSet($optional[$property]))
|
||||
{
|
||||
if($optional[$property])
|
||||
{
|
||||
$this->error=("optional ".$scope." property \"".$property."\" is already set");
|
||||
return 0;
|
||||
}
|
||||
$optional[$property]=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GetType($colon=strpos($property,":",0))=="integer")
|
||||
{
|
||||
$namespace=substr($property,0,$colon);
|
||||
if(!(!strcmp($namespace,"rdf") || IsSet($this->rssnamespaces[$namespace])))
|
||||
$this->error=("the name space of property \"".$property."\" was not declared");
|
||||
}
|
||||
else
|
||||
$this->error=("\"".$property."\" is not a supported ".$scope." property");
|
||||
}
|
||||
}
|
||||
if(!($this->adddatatag($property,$noattributes,$properties[$property],$parent,$path)))
|
||||
return 0;
|
||||
Next($properties);
|
||||
$end=(GetType($property=Key($properties))!="string");
|
||||
}
|
||||
if($required_properties<count($required))
|
||||
{
|
||||
Reset($required);
|
||||
$end=(GetType($property=Key($required))!="string");
|
||||
for(;!$end;)
|
||||
{
|
||||
if(!($required[$property]))
|
||||
{
|
||||
$this->error=("it was not specified the required ".$scope." property \"".$property."\"");
|
||||
return 0;
|
||||
}
|
||||
Next($required);
|
||||
$end=(GetType($property=Key($required))!="string");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Public functions
|
||||
*
|
||||
*/
|
||||
Function addchannel(&$properties)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
if(strcmp($this->channel,""))
|
||||
{
|
||||
$this->error="a channel was already added";
|
||||
return 0;
|
||||
}
|
||||
$channel_attributes=array();
|
||||
switch($this->specification)
|
||||
{
|
||||
case "0.9":
|
||||
$root="rdf:RDF";
|
||||
$attributes=array("xmlns:rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns"=>"http://my.netscape.com/rdf/simple/0.9/");
|
||||
$required=array("description"=>0,"link"=>0,"title"=>0);
|
||||
$optional=array();
|
||||
break;
|
||||
case "0.91":
|
||||
$root="rss";
|
||||
$attributes=array("version"=>$this->specification);
|
||||
$required=array("description"=>0,"language"=>0,"link"=>0,"title"=>0);
|
||||
$optional=array("copyright"=>0,"docs"=>0,"lastBuildDate"=>0,"managingEditor"=>0,"pubDate"=>0,"rating"=>0,"webMaster"=>0);
|
||||
break;
|
||||
case "1.0":
|
||||
if(!strcmp($this->about,""))
|
||||
{
|
||||
$this->error="it was not specified the about URL attribute";
|
||||
return 0;
|
||||
}
|
||||
$root="rdf:RDF";
|
||||
$attributes=array("xmlns:rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns"=>"http://purl.org/rss/1.0/");
|
||||
Reset($this->rssnamespaces);
|
||||
$end=(GetType($namespace=Key($this->rssnamespaces))!="string");
|
||||
for(;!$end;)
|
||||
{
|
||||
if(!strcmp($namespace,"rdf"))
|
||||
{
|
||||
$this->error="the rdf namespace is being redeclared";
|
||||
return 0;
|
||||
}
|
||||
$attributes[("xmlns:".$namespace)]=$this->rssnamespaces[$namespace];
|
||||
Next($this->rssnamespaces);
|
||||
$end=(GetType($namespace=Key($this->rssnamespaces))!="string");
|
||||
}
|
||||
$channel_attributes=array("rdf:about"=>$this->about);
|
||||
$required=array("description"=>0,"link"=>0,"title"=>0);
|
||||
$optional=array();
|
||||
break;
|
||||
default:
|
||||
$this->error="it was not specified a supported RSS specification version";
|
||||
return 0;
|
||||
}
|
||||
$this->addtag($root,$attributes,"",$path,1);
|
||||
$this->root=$path;
|
||||
if(!($this->addtag("channel",$channel_attributes,$this->root,$path,1)))
|
||||
return 0;
|
||||
if(!($this->addrssproperties($properties,$path,$required,$optional,"channel")))
|
||||
return 0;
|
||||
$this->channel=$path;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function additem(&$properties)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
if(!strcmp($this->channel,""))
|
||||
{
|
||||
$this->error="the channel was not yet added";
|
||||
return 0;
|
||||
}
|
||||
if(strcmp($this->textinput,""))
|
||||
{
|
||||
$this->error="items can not be added to the channel after defining the textinput";
|
||||
return 0;
|
||||
}
|
||||
$attributes=array();
|
||||
switch($this->specification)
|
||||
{
|
||||
case "0.9":
|
||||
$parent=$this->root;
|
||||
break;
|
||||
case "0.91":
|
||||
$parent=$this->channel;
|
||||
break;
|
||||
case "1.0":
|
||||
if(IsSet($properties["link"]))
|
||||
$attributes["rdf:about"]=$properties["link"];
|
||||
$parent=$this->root;
|
||||
break;
|
||||
default:
|
||||
$this->error="it was not specified a supported RSS specification version";
|
||||
return 0;
|
||||
}
|
||||
if(!($this->addtag("item",$attributes,$parent,$path,1)))
|
||||
return 0;
|
||||
$required=array("link"=>0,"title"=>0);
|
||||
$optional=array("description"=>0);
|
||||
if(!($this->addrssproperties($properties,$path,$required,$optional,"item")))
|
||||
return 0;
|
||||
if(!strcmp($this->specification,"1.0"))
|
||||
{
|
||||
if(!strcmp($this->itemsequence,""))
|
||||
{
|
||||
$attributes=array();
|
||||
if(!($this->addtag("items",$attributes,$this->channel,$path,1) && $this->addtag("rdf:Seq",$attributes,$path,$path,1)))
|
||||
return 0;
|
||||
$this->itemsequence=$path;
|
||||
}
|
||||
$attributes=array("rdf:resource"=>$properties["link"]);
|
||||
if(!($this->addtag("rdf:li",$attributes,$this->itemsequence,$path,0)))
|
||||
return 0;
|
||||
}
|
||||
$this->items++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function addimage(&$properties)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
if(!strcmp($this->channel,""))
|
||||
{
|
||||
$this->error="the channel was not yet added";
|
||||
return 0;
|
||||
}
|
||||
if(strcmp($this->image,""))
|
||||
{
|
||||
$this->error="the channel image was already associated";
|
||||
return 0;
|
||||
}
|
||||
if($this->items!=0)
|
||||
{
|
||||
$this->error="the image can only be defined before adding the channel items";
|
||||
return 0;
|
||||
}
|
||||
$attributes=array();
|
||||
switch($this->specification)
|
||||
{
|
||||
case "0.9":
|
||||
$parent=$this->root;
|
||||
break;
|
||||
case "0.91":
|
||||
$parent=$this->channel;
|
||||
break;
|
||||
case "1.0":
|
||||
if(IsSet($properties["url"]))
|
||||
$attributes["rdf:about"]=$properties["url"];
|
||||
$parent=$this->root;
|
||||
break;
|
||||
default:
|
||||
$this->error="it was not specified a supported RSS specification version";
|
||||
return 0;
|
||||
}
|
||||
if(!($this->addtag("image",$attributes,$parent,$path,1)))
|
||||
return 0;
|
||||
$this->image=$path;
|
||||
$required=array("link"=>0,"title"=>0,"url"=>0);
|
||||
$optional=array("description"=>0,"width"=>0,"height"=>0);
|
||||
if(!($this->addrssproperties($properties,$this->image,$required,$optional,"image")))
|
||||
return 0;
|
||||
if(!strcmp($this->specification,"1.0"))
|
||||
{
|
||||
$attributes=array("rdf:resource"=>$properties["url"]);
|
||||
return $this->addtag("image",$attributes,$this->channel,$path,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function addtextinput(&$properties)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
if(!strcmp($this->channel,""))
|
||||
{
|
||||
$this->error="the channel was not yet added";
|
||||
return 0;
|
||||
}
|
||||
if(strcmp($this->textinput,""))
|
||||
{
|
||||
$this->error="the channel text input was already associated";
|
||||
return 0;
|
||||
}
|
||||
if($this->items==0 && !$this->allownoitems)
|
||||
{
|
||||
$this->error="it were not specified any items before defining the channel text input";
|
||||
return 0;
|
||||
}
|
||||
$attributes=array();
|
||||
switch($this->specification)
|
||||
{
|
||||
case "0.9":
|
||||
$parent=$this->root;
|
||||
break;
|
||||
case "0.91":
|
||||
$parent=$this->channel;
|
||||
break;
|
||||
case "1.0":
|
||||
if(IsSet($properties["link"]))
|
||||
$attributes["rdf:about"]=$properties["link"];
|
||||
$parent=$this->root;
|
||||
break;
|
||||
default:
|
||||
$this->error="it was not specified a supported RSS specification version";
|
||||
return 0;
|
||||
}
|
||||
if(!($this->addtag("textinput",$attributes,$parent,$path,1)))
|
||||
return 0;
|
||||
$this->textinput=$path;
|
||||
$required=array("description"=>0,"link"=>0,"name"=>0,"title"=>0);
|
||||
$optional=array();
|
||||
if(!($this->addrssproperties($properties,$this->textinput,$required,$optional,"textinput")))
|
||||
return 0;
|
||||
if(!strcmp($this->specification,"1.0"))
|
||||
{
|
||||
$attributes=array("rdf:resource"=>$properties["link"]);
|
||||
return $this->addtag("textinput",$attributes,$this->channel,$path,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function writerss(&$output)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
if(!strcmp($this->channel,""))
|
||||
{
|
||||
$this->error="it was not defined the RSS channel";
|
||||
return 0;
|
||||
}
|
||||
if($this->items==0 && !$this->allownoitems)
|
||||
{
|
||||
$this->error="it were not defined any RSS channel items";
|
||||
return 0;
|
||||
}
|
||||
switch($this->specification)
|
||||
{
|
||||
case "0.9":
|
||||
$this->dtdtype="PUBLIC";
|
||||
$this->dtddefinition="-//Netscape Communications//DTD RSS 0.9//EN";
|
||||
$this->dtdurl="http://my.netscape.com/publish/formats/rss-0.9.dtd";
|
||||
break;
|
||||
case "0.91":
|
||||
$this->dtdtype="PUBLIC";
|
||||
$this->dtddefinition="-//Netscape Communications//DTD RSS 0.91//EN";
|
||||
$this->dtdurl="http://my.netscape.com/publish/formats/rss-0.91.dtd";
|
||||
break;
|
||||
case "1.0":
|
||||
$this->dtdtype="";
|
||||
break;
|
||||
default:
|
||||
$this->error="it was not specified a supported RSS specification version";
|
||||
return 0;
|
||||
}
|
||||
return $this->write($output);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
?>
|
656
tests/lib/test_manager.php
Normal file
656
tests/lib/test_manager.php
Normal file
|
@ -0,0 +1,656 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
||||
*
|
||||
* Portions modifiied from WACT Test Suite
|
||||
* Author(s): Harry Fuecks
|
||||
* Jon Ramsey
|
||||
* Jason E. Sweat
|
||||
* Franco Ponticelli
|
||||
* Lorenzo Alberton
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/TestSuite/Authors/ Authors/Developers
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class TestManager
|
||||
{
|
||||
var $_testExtension = '.test.php';
|
||||
var $_groupExtension = '.group.php';
|
||||
var $usersAppTest = false;
|
||||
|
||||
function TestManager()
|
||||
{
|
||||
$this->_installSimpleTest();
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
$this->usersAppTest = true;
|
||||
}
|
||||
}
|
||||
|
||||
function _installSimpleTest()
|
||||
{
|
||||
require_once SIMPLE_TEST . 'unit_tester.php';
|
||||
require_once SIMPLE_TEST . 'web_tester.php';
|
||||
require_once SIMPLE_TEST . 'mock_objects.php';
|
||||
}
|
||||
|
||||
function setOutputFromIni($iniFile)
|
||||
{
|
||||
if (! file_exists($iniFile))
|
||||
{
|
||||
trigger_error("Missing configuration file {$iniFile}", E_USER_ERROR);
|
||||
}
|
||||
$config = parse_ini_file($iniFile, TRUE);
|
||||
foreach ($config['output'] as $key => $value)
|
||||
{
|
||||
define($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
function runAllTests(&$reporter)
|
||||
{
|
||||
$manager =& new TestManager();
|
||||
|
||||
if(!empty($manager->usersAppTest))
|
||||
{
|
||||
$testCasePath = APP_TEST_CASES . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
$testCasePath = CORE_TEST_CASES . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
$testCases =& $manager->_getTestFileList($testCasePath);
|
||||
$test =& new GroupTest('All Tests');
|
||||
|
||||
foreach ($testCases as $testCase)
|
||||
{
|
||||
$test->addTestFile($testCase);
|
||||
}
|
||||
$test->run($reporter);
|
||||
}
|
||||
|
||||
function runTestCase($testCaseFile, &$reporter)
|
||||
{
|
||||
$manager =& new TestManager();
|
||||
|
||||
if(!empty($manager->usersAppTest))
|
||||
{
|
||||
$testCaseFileWithPath = APP_TEST_CASES . DIRECTORY_SEPARATOR . $testCaseFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
$testCaseFileWithPath = CORE_TEST_CASES . DIRECTORY_SEPARATOR . $testCaseFile;
|
||||
}
|
||||
|
||||
if (! file_exists($testCaseFileWithPath))
|
||||
{
|
||||
trigger_error("Test case {$testCaseFile} cannot be found", E_USER_ERROR);
|
||||
}
|
||||
|
||||
$test =& new GroupTest("Individual test case: " . $testCaseFile);
|
||||
$test->addTestFile($testCaseFileWithPath);
|
||||
$test->run($reporter);
|
||||
}
|
||||
|
||||
function runGroupTest($groupTestName, $groupTestDirectory, &$reporter)
|
||||
{
|
||||
$manager =& new TestManager();
|
||||
|
||||
$filePath = $groupTestDirectory . DIRECTORY_SEPARATOR .
|
||||
strtolower($groupTestName) . $manager->_groupExtension;
|
||||
|
||||
if (! file_exists($filePath))
|
||||
{
|
||||
trigger_error("Group test {$groupTestName} cannot be found at {$filePath}", E_USER_ERROR);
|
||||
}
|
||||
|
||||
require_once $filePath;
|
||||
$test =& new GroupTest($groupTestName . ' group test');
|
||||
|
||||
foreach ($manager->_getGroupTestClassNames($filePath) as $groupTest)
|
||||
{
|
||||
$test->addTestCase(new $groupTest());
|
||||
}
|
||||
$test->run($reporter);
|
||||
}
|
||||
|
||||
function addTestCasesFromDirectory(&$groupTest, $directory = '.')
|
||||
{
|
||||
$manager =& new TestManager();
|
||||
$testCases =& $manager->_getTestFileList($directory);
|
||||
foreach ($testCases as $testCase)
|
||||
{
|
||||
$groupTest->addTestFile($testCase);
|
||||
}
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.')
|
||||
{
|
||||
$manager =& new TestManager();
|
||||
return $manager->_getTestCaseList($directory);
|
||||
}
|
||||
|
||||
function &_getTestCaseList($directory = '.')
|
||||
{
|
||||
$fileList =& $this->_getTestFileList($directory);
|
||||
$testCases = array();
|
||||
foreach ($fileList as $testCaseFile)
|
||||
{
|
||||
$testCases[$testCaseFile] = str_replace($directory . '/', '', $testCaseFile);
|
||||
}
|
||||
return $testCases;
|
||||
}
|
||||
|
||||
function &_getTestFileList($directory = '.')
|
||||
{
|
||||
return $this->_getRecursiveFileList($directory, array(&$this, '_isTestCaseFile'));
|
||||
}
|
||||
|
||||
function &getGroupTestList($directory = '.')
|
||||
{
|
||||
$manager =& new TestManager();
|
||||
return $manager->_getTestGroupList($directory);
|
||||
}
|
||||
|
||||
function &_getTestGroupFileList($directory = '.')
|
||||
{
|
||||
return $this->_getRecursiveFileList($directory, array(&$this, '_isTestGroupFile'));
|
||||
}
|
||||
|
||||
function &_getTestGroupList($directory = '.')
|
||||
{
|
||||
$fileList =& $this->_getTestGroupFileList($directory);
|
||||
$groupTests = array();
|
||||
|
||||
foreach ($fileList as $groupTestFile)
|
||||
{
|
||||
$groupTests[$groupTestFile] = str_replace($this->_groupExtension, '', basename($groupTestFile));
|
||||
}
|
||||
sort($groupTests);
|
||||
return $groupTests;
|
||||
}
|
||||
|
||||
function &_getGroupTestClassNames($groupTestFile)
|
||||
{
|
||||
$file = implode("\n", file($groupTestFile));
|
||||
preg_match("~lass\s+?(.*)\s+?extends GroupTest~", $file, $matches);
|
||||
if (! empty($matches))
|
||||
{
|
||||
unset($matches[0]);
|
||||
return $matches;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
function &_getRecursiveFileList($directory = '.', $fileTestFunction) {
|
||||
$dh = opendir($directory);
|
||||
if (! is_resource($dh))
|
||||
{
|
||||
trigger_error("Couldn't open {$directory}", E_USER_ERROR);
|
||||
}
|
||||
|
||||
$fileList = array();
|
||||
while ($file = readdir($dh))
|
||||
{
|
||||
$filePath = $directory . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
if (0 === strpos($file, '.')) continue;
|
||||
|
||||
if (is_dir($filePath))
|
||||
{
|
||||
$fileList = array_merge($fileList,
|
||||
$this->_getRecursiveFileList($filePath,
|
||||
$fileTestFunction));
|
||||
}
|
||||
if ($fileTestFunction[0]->$fileTestFunction[1]($file))
|
||||
{
|
||||
$fileList[] = $filePath;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
return $fileList;
|
||||
}
|
||||
|
||||
function _isTestCaseFile($file) {
|
||||
return $this->_hasExpectedExtension($file, $this->_testExtension);
|
||||
}
|
||||
|
||||
function _isTestGroupFile($file) {
|
||||
return $this->_hasExpectedExtension($file, $this->_groupExtension);
|
||||
}
|
||||
|
||||
function _hasExpectedExtension($file, $extension) {
|
||||
return $extension ==
|
||||
strtolower(substr($file, (0 - strlen($extension))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class CliTestManager extends TestManager
|
||||
{
|
||||
|
||||
function &getGroupTestList($directory = '.')
|
||||
{
|
||||
$manager =& new CliTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($directory);
|
||||
|
||||
$buffer = "Available Group Test:\n";
|
||||
foreach ($groupTests as $groupTest)
|
||||
{
|
||||
$buffer .= " " . $groupTest . "\n";
|
||||
}
|
||||
return $buffer . "\n";
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.')
|
||||
{
|
||||
$manager =& new CliTestManager();
|
||||
$testCases =& $manager->_getTestCaseList($directory);
|
||||
|
||||
$buffer = "Available Test Cases:\n";
|
||||
foreach ($testCases as $testCaseFile => $testCase)
|
||||
{
|
||||
$buffer .= " " . $testCaseFile . "\n";
|
||||
}
|
||||
return $buffer . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class TextTestManager extends TestManager {
|
||||
var $_url;
|
||||
|
||||
function TextTestManager()
|
||||
{
|
||||
$this->_url = $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
function getBaseURL()
|
||||
{
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
function &getGroupTestList($directory = '.')
|
||||
{
|
||||
$manager =& new TextTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($directory);
|
||||
|
||||
if (1 > count($groupTests))
|
||||
{
|
||||
return "No test groups set up!\n";
|
||||
}
|
||||
|
||||
$buffer = "Available test groups:\n";
|
||||
$buffer .= $manager->getBaseURL() . "?group=all All tests<\n";
|
||||
foreach ($groupTests as $groupTest)
|
||||
{
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}'>" .
|
||||
$groupTest . "&output=txt"."</a></li>\n";
|
||||
}
|
||||
return $buffer . "</ul>\n";
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.')
|
||||
{
|
||||
$manager =& new TextTestManager();
|
||||
$testCases =& $manager->_getTestCaseList($directory);
|
||||
|
||||
if (1 > count($testCases)) {
|
||||
return "No test cases set up!";
|
||||
}
|
||||
$buffer = "Available test cases:\n";
|
||||
foreach ($testCases as $testCaseFile => $testCase)
|
||||
{
|
||||
$buffer .= $_SERVER['SERVER_NAME'].
|
||||
$manager->getBaseURL()."?case=" .
|
||||
$testCase . "&output=txt"."\n";
|
||||
|
||||
}
|
||||
return $buffer . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class HtmlTestManager extends TestManager {
|
||||
var $_url;
|
||||
|
||||
function HtmlTestManager()
|
||||
{
|
||||
$this->_url = $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
function getBaseURL()
|
||||
{
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
function &getGroupTestList($directory = '.')
|
||||
{
|
||||
$userApp = '';
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
$userApp = '&app=true';
|
||||
}
|
||||
$manager =& new HtmlTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($directory);
|
||||
|
||||
if (1 > count($groupTests))
|
||||
{
|
||||
return "<p>No test groups set up!</p>";
|
||||
}
|
||||
|
||||
$buffer = "<p>Available test groups:</p>\n<ul>";
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group=all$userApp'>All tests</a></li>\n";
|
||||
foreach ($groupTests as $groupTest)
|
||||
{
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}'>" .
|
||||
$groupTest . $userApp ."</a></li>\n";
|
||||
}
|
||||
return $buffer . "</ul>\n";
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.')
|
||||
{
|
||||
$userApp = '';
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
$userApp = '&app=true';
|
||||
}
|
||||
$manager =& new HtmlTestManager();
|
||||
$testCases =& $manager->_getTestCaseList($directory);
|
||||
|
||||
if (1 > count($testCases)) {
|
||||
return "<p>No test cases set up!</p>";
|
||||
}
|
||||
$buffer = "<p>Available test cases:</p>\n<ul>";
|
||||
foreach ($testCases as $testCaseFile => $testCase)
|
||||
{
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() .
|
||||
"?case=" . urlencode($testCase) . $userApp ."'>" .
|
||||
$testCase . "</a></li>\n";
|
||||
}
|
||||
return $buffer . "</ul>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class XmlTestManager extends HtmlTestManager
|
||||
{
|
||||
|
||||
function XmlTestManager()
|
||||
{
|
||||
parent::HtmlTestManager();
|
||||
}
|
||||
|
||||
function &getGroupTestList($directory = '.')
|
||||
{
|
||||
$userApp = '';
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
$userApp = '&app=true';
|
||||
}
|
||||
|
||||
$manager =& new XmlTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($directory);
|
||||
|
||||
$rss = & $manager->_getRssWriter();
|
||||
|
||||
if (1 > count($groupTests))
|
||||
{
|
||||
$rss->writeRss($output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
$properties["title"]="All Tests";
|
||||
$properties["description"]="All Tests";
|
||||
$properties["link"]='http://'.$_SERVER['SERVER_NAME'].
|
||||
$manager->getBaseURL()."?group=all&output=xml".$userApp;
|
||||
|
||||
$rss->additem($properties);
|
||||
|
||||
foreach ($groupTests as $groupTest)
|
||||
{
|
||||
$properties["title"]=$groupTest;
|
||||
$properties["description"]=$groupTest;
|
||||
$properties["link"]='http://'.$_SERVER['SERVER_NAME'].
|
||||
$manager->getBaseURL().
|
||||
"?group={$groupTest}&output=xml.$userApp";
|
||||
|
||||
$rss->additem($properties);
|
||||
}
|
||||
$rss->writeRss($output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.')
|
||||
{
|
||||
$userApp = '';
|
||||
if (isset($_GET['app']))
|
||||
{
|
||||
$userApp = '&app=true';
|
||||
}
|
||||
|
||||
$manager =& new XmlTestManager();
|
||||
|
||||
$testCases =& $manager->_getTestCaseList($directory);
|
||||
|
||||
$rss = & $manager->_getRssWriter();
|
||||
|
||||
if (1 > count($testCases)) {
|
||||
$rss->writeRss($output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
foreach ($testCases as $testCaseFile => $testCase)
|
||||
{
|
||||
$properties["title"]=$testCase;
|
||||
$properties["description"]=$testCase;
|
||||
$properties["link"]='http://'.$_SERVER['SERVER_NAME'].
|
||||
$manager->getBaseURL()."?case=" .
|
||||
urlencode($testCase) . "&output=xml" . $userApp;
|
||||
|
||||
// Comment this out for performance?
|
||||
$properties["dc:date"]=gmdate("Y-m-d\TH:i:sO",filemtime($testCaseFile));
|
||||
|
||||
$rss->additem($properties);
|
||||
}
|
||||
$rss->writeRss($output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
function &_getRssWriter()
|
||||
{
|
||||
|
||||
$cakeUrl = 'http://'.$_SERVER['SERVER_NAME'].str_replace('index.php','',$_SERVER['PHP_SELF']);
|
||||
|
||||
require_once TESTS . 'lib'.DIRECTORY_SEPARATOR.'xml_writer_class.php';
|
||||
require_once TESTS . 'lib'.DIRECTORY_SEPARATOR.'rss_writer_class.php';
|
||||
|
||||
$rssWriterObject =& new rss_writer_class();
|
||||
$rssWriterObject->specification="1.0";
|
||||
$rssWriterObject->about=$cakeUrl."index.php?output=xml";
|
||||
$rssWriterObject->stylesheet=$cakeUrl."rss2html.xsl";
|
||||
$rssWriterObject->rssnamespaces["dc"]="http://purl.org/dc/elements/1.1/";
|
||||
|
||||
// Channel Properties
|
||||
$properties=array();
|
||||
$properties["title"]="CakePHP Unit Test Cases";
|
||||
$properties["description"]="CakePHP Unit Test Cases";
|
||||
$properties["link"]="http://www.cakephp.org/";
|
||||
$properties["dc:date"]=gmdate("Y-m-d\TH:i:sO");
|
||||
$rssWriterObject->addchannel($properties);
|
||||
|
||||
|
||||
$properties=array();
|
||||
$properties["url"]="http://www.cakephp.org/img/cake.png";
|
||||
$properties["link"]="http://www.cakephp.org/";
|
||||
$properties["title"]="CakePHP Logo";
|
||||
$properties["description"]="CakePHP : Rapid Development Framework";
|
||||
$rssWriterObject->addimage($properties);
|
||||
|
||||
|
||||
return $rssWriterObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class RemoteTestManager extends TestManager {
|
||||
|
||||
function RemoteTestManager()
|
||||
{
|
||||
parent::TestManager();
|
||||
}
|
||||
|
||||
function _installSimpleTest()
|
||||
{
|
||||
parent::_installSimpleTest();
|
||||
require_once SIMPLE_TEST . 'remote.php';
|
||||
}
|
||||
|
||||
function runAllTests(&$reporter, $url = FALSE)
|
||||
{
|
||||
$groups = RemoteTestManager::getGroupTestList($url);
|
||||
$T =& new RemoteTestCase($groups['All Tests']);
|
||||
$T->run($reporter);
|
||||
}
|
||||
|
||||
function runTestCase($caseFile,& $reporter, $url = FALSE)
|
||||
{
|
||||
$cases = RemoteTestManager::getTestCaseList($url);
|
||||
$T =& new RemoteTestCase($cases[$caseFile]);
|
||||
$T->run($reporter);
|
||||
}
|
||||
|
||||
function runGroupTest($groupName, &$reporter, $url = FALSE)
|
||||
{
|
||||
$groups = RemoteTestManager::getGroupTestList($url);
|
||||
$T =& new RemoteTestCase($groups[$groupName]);
|
||||
$T->run($reporter);
|
||||
}
|
||||
|
||||
function & getGroupTestList($url = FALSE)
|
||||
{
|
||||
|
||||
if ( !$url )
|
||||
{
|
||||
$url = REMOTE_TEST_HTTP_PATH;
|
||||
}
|
||||
|
||||
$url .= '?output=xml';
|
||||
|
||||
$manager =& new RemoteTestManager();
|
||||
$rss = & $manager->_getRssReader($url);
|
||||
|
||||
$groupList = array();
|
||||
|
||||
foreach ($rss->getItems() as $item)
|
||||
{
|
||||
$groupList[$item['title']] = $item['link'];
|
||||
}
|
||||
|
||||
return $groupList;
|
||||
}
|
||||
|
||||
function &getTestCaseList($url = FALSE)
|
||||
{
|
||||
if ( !$url )
|
||||
{
|
||||
$url = REMOTE_TEST_HTTP_PATH;
|
||||
}
|
||||
|
||||
$url .= '?show=cases&output=xml';
|
||||
|
||||
$manager =& new RemoteTestManager();
|
||||
$rss = & $manager->_getRssReader($url);
|
||||
|
||||
$caseList = array();
|
||||
|
||||
foreach ($rss->getItems() as $item)
|
||||
{
|
||||
$caseList[$item['title']] = $item['link'];
|
||||
}
|
||||
|
||||
return $caseList;
|
||||
}
|
||||
|
||||
function &_getRssReader($url)
|
||||
{
|
||||
require_once "XML/RSS.php";
|
||||
|
||||
$rssReader =& new XML_RSS($url);
|
||||
|
||||
$status = $rssReader->parse();
|
||||
|
||||
if (PEAR::isError($status) )
|
||||
{
|
||||
trigger_error($status->getMessage(),E_USER_WARNING);
|
||||
}
|
||||
return $rssReader;
|
||||
}
|
||||
}
|
||||
?>
|
312
tests/lib/xml_writer_class.php
Normal file
312
tests/lib/xml_writer_class.php
Normal file
|
@ -0,0 +1,312 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id:*/
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* Copyright (c) Manuel Lemos 2001-2002
|
||||
*
|
||||
* Licensed under The BSD License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @author Manuel Lemos
|
||||
* @copyright Copyright (c) 2001-2002, Manuel Lemos
|
||||
* @package tests
|
||||
* @subpackage tests.lib
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/bsd-license.html BSD
|
||||
*/
|
||||
|
||||
if(!defined("METAL_LIBRARY_XML_XML_WRITER_CLASS"))
|
||||
{
|
||||
define("METAL_LIBRARY_XML_XML_WRITER_CLASS",1);
|
||||
|
||||
|
||||
class xml_writer_class
|
||||
{
|
||||
/*
|
||||
* Protected variables
|
||||
*
|
||||
*/
|
||||
var $structure=array();
|
||||
var $nodes=array();
|
||||
|
||||
/*
|
||||
* Public variables
|
||||
*
|
||||
*/
|
||||
var $stylesheet="";
|
||||
var $stylesheettype="text/xsl";
|
||||
var $dtdtype="";
|
||||
var $dtddefinition="";
|
||||
var $dtdurl="";
|
||||
var $outputencoding="utf-8";
|
||||
var $inputencoding="iso-8859-1";
|
||||
var $linebreak="\n";
|
||||
var $indenttext=" ";
|
||||
var $generatedcomment="Generated by: http://www.phpclasses.org/xmlwriter";
|
||||
var $error="";
|
||||
|
||||
|
||||
/*
|
||||
* Protected functions
|
||||
*
|
||||
*/
|
||||
Function escapedata($data)
|
||||
{
|
||||
$position=0;
|
||||
$length=strlen($data);
|
||||
$escapeddata="";
|
||||
for(;$position<$length;)
|
||||
{
|
||||
$character=substr($data,$position,1);
|
||||
$code=Ord($character);
|
||||
switch($code)
|
||||
{
|
||||
case 34:
|
||||
$character=""";
|
||||
break;
|
||||
case 38:
|
||||
$character="&";
|
||||
break;
|
||||
case 39:
|
||||
$character="'";
|
||||
break;
|
||||
case 60:
|
||||
$character="<";
|
||||
break;
|
||||
case 62:
|
||||
$character=">";
|
||||
break;
|
||||
default:
|
||||
if($code<32)
|
||||
$character=("&#".strval($code).";");
|
||||
break;
|
||||
}
|
||||
$escapeddata.=$character;
|
||||
$position++;
|
||||
}
|
||||
return $escapeddata;
|
||||
}
|
||||
|
||||
Function encodedata($data,&$encodeddata)
|
||||
{
|
||||
if(!strcmp($this->inputencoding,$this->outputencoding))
|
||||
$encodeddata=$this->escapedata($data);
|
||||
else
|
||||
{
|
||||
switch(strtolower($this->outputencoding))
|
||||
{
|
||||
case "utf-8":
|
||||
if(!strcmp(strtolower($this->inputencoding),"iso-8859-1"))
|
||||
{
|
||||
$encoded_data=utf8_encode($this->escapedata($data));
|
||||
$encodeddata=$encoded_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=("can not encode iso-8859-1 data in ".$this->outputencoding);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case "iso-8859-1":
|
||||
if(!strcmp(strtolower($this->inputencoding),"utf-8"))
|
||||
{
|
||||
$decoded=utf8_decode($data);
|
||||
$encodeddata=$this->escapedata($decoded);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=("can not encode utf-8 data in ".$this->outputencoding);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error=("can not encode data in ".$this->inputencoding);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function writetag(&$output,$path,$indent)
|
||||
{
|
||||
$tag=$this->structure[$path]["Tag"];
|
||||
$output.=("<".$tag);
|
||||
$attributecount=count($this->structure[$path]["Attributes"]);
|
||||
if($attributecount>0)
|
||||
{
|
||||
$attributes=$this->structure[$path]["Attributes"];
|
||||
Reset($attributes);
|
||||
$end=(GetType($key=Key($attributes))!="string");
|
||||
for(;!$end;)
|
||||
{
|
||||
$output.=(" ".$key."=\"".$attributes[$key]."\"");
|
||||
Next($attributes);
|
||||
$end=(GetType($key=Key($attributes))!="string");
|
||||
}
|
||||
}
|
||||
$elements=$this->structure[$path]["Elements"];
|
||||
if($elements>0)
|
||||
{
|
||||
$output.=">";
|
||||
$doindent=$this->structure[$path]["Indent"];
|
||||
$elementindent=(($doindent) ? $this->linebreak.$indent.$this->indenttext : "");
|
||||
$element=0;
|
||||
for(;$element<$elements;)
|
||||
{
|
||||
$elementpath=($path.",".strval($element));
|
||||
$output.=$elementindent;
|
||||
if(IsSet($this->nodes[$elementpath]))
|
||||
{
|
||||
if(!($this->writetag($output,$elementpath,$indent.$this->indenttext)))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
$output.=$this->structure[$elementpath];
|
||||
$element++;
|
||||
}
|
||||
$output.=((($doindent) ? $this->linebreak.$indent : "")."</".$tag.">");
|
||||
}
|
||||
else
|
||||
$output.="/>";
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Public functions
|
||||
*
|
||||
*/
|
||||
Function write(&$output)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
if(!(IsSet($this->structure["0"])))
|
||||
{
|
||||
$this->error="XML document structure is empty";
|
||||
return 0;
|
||||
}
|
||||
$output=("<?xml version=\"1.0\" encoding=\"".$this->outputencoding."\"?>".$this->linebreak);
|
||||
if(strcmp($this->dtdtype,""))
|
||||
{
|
||||
$output.=("<!DOCTYPE ".$this->structure["0"]["Tag"]." ");
|
||||
switch($this->dtdtype)
|
||||
{
|
||||
case "INTERNAL":
|
||||
if(!strcmp($this->dtddefinition,""))
|
||||
{
|
||||
$this->error="it was not specified a valid internal DTD definition";
|
||||
return 0;
|
||||
}
|
||||
$output.=("[".$this->linebreak.$this->dtddefinition.$this->linebreak."]");
|
||||
break;
|
||||
case "SYSTEM":
|
||||
if(!strcmp($this->dtdurl,""))
|
||||
{
|
||||
$this->error="it was not specified a valid system DTD url";
|
||||
return 0;
|
||||
}
|
||||
$output.="SYSTEM";
|
||||
if(strcmp($this->dtddefinition,""))
|
||||
$output.=(" \"".$this->dtddefinition."\"");
|
||||
$output.=(" \"".$this->dtdurl."\"");
|
||||
break;
|
||||
case "PUBLIC":
|
||||
if(!strcmp($this->dtddefinition,""))
|
||||
{
|
||||
$this->error="it was not specified a valid public DTD definition";
|
||||
return 0;
|
||||
}
|
||||
$output.=("PUBLIC \"".$this->dtddefinition."\"");
|
||||
if(strcmp($this->dtdurl,""))
|
||||
$output.=(" \"".$this->dtdurl."\"");
|
||||
break;
|
||||
default:
|
||||
$this->error="it was not specified a valid DTD type";
|
||||
return 0;
|
||||
}
|
||||
$output.=(">".$this->linebreak);
|
||||
}
|
||||
if(strcmp($this->stylesheet,""))
|
||||
{
|
||||
if(!strcmp($this->stylesheettype,""))
|
||||
{
|
||||
$this->error="it was not specified a valid stylesheet type";
|
||||
return 0;
|
||||
}
|
||||
$output.=("<?xml-stylesheet type=\"".$this->stylesheettype."\" href=\"".$this->stylesheet."\"?>".$this->linebreak);
|
||||
}
|
||||
if(strcmp($this->generatedcomment,""))
|
||||
$output.=("<!-- ".$this->generatedcomment." -->".$this->linebreak);
|
||||
return $this->writetag($output,"0","");
|
||||
}
|
||||
|
||||
Function addtag($tag,&$attributes,$parent,&$path,$indent)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
$path=((!strcmp($parent,"")) ? "0" : ($parent.",".strval($this->structure[$parent]["Elements"])));
|
||||
if(IsSet($this->structure[$path]))
|
||||
{
|
||||
$this->error=("tag with path ".$path." is already defined");
|
||||
return 0;
|
||||
}
|
||||
$encodedattributes=array();
|
||||
Reset($attributes);
|
||||
$end=(GetType($attribute_name=Key($attributes))!="string");
|
||||
for(;!$end;)
|
||||
{
|
||||
$encodedattributes[$attribute_name]="";
|
||||
if(!($this->encodedata($attributes[$attribute_name],$encoded_data)))
|
||||
return 0;
|
||||
$encodedattributes[$attribute_name]=$encoded_data;
|
||||
Next($attributes);
|
||||
$end=(GetType($attribute_name=Key($attributes))!="string");
|
||||
}
|
||||
$this->structure[$path]=array(
|
||||
"Tag"=>$tag,
|
||||
"Attributes"=>$encodedattributes,
|
||||
"Elements"=>0,
|
||||
"Indent"=>$indent
|
||||
);
|
||||
$this->nodes[$path]=1;
|
||||
if(strcmp($parent,""))
|
||||
$this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function adddata($data,$parent,&$path)
|
||||
{
|
||||
if(strcmp($this->error,""))
|
||||
return 0;
|
||||
if(!(IsSet($this->structure[$parent])))
|
||||
{
|
||||
$this->error=("the parent tag path".$path."is not defined");
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp($data,""))
|
||||
return 1;
|
||||
$path=($parent.",".strval($this->structure[$parent]["Elements"]));
|
||||
if(!($this->encodedata($data,$encoded_data)))
|
||||
return 0;
|
||||
$this->structure[$path]=$encoded_data;
|
||||
$this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function adddatatag($tag,&$attributes,$data,$parent,&$path)
|
||||
{
|
||||
return $this->addtag($tag,$attributes,$parent,$path,0) && $this->adddata($data,$path,$datapath);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
?>
|
110
tests/rss2html.xsl
Normal file
110
tests/rss2html.xsl
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!--
|
||||
@(#) $Id$
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rss="http://purl.org/rss/1.0/" xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<xsl:output method="html"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
||||
<style type="text/css">
|
||||
div.channel-title { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.image { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.image-description { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.item-title { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.item-description { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.textinput-title { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div.textinput-form { font-family: sans-serif, arial, helvetica }
|
||||
</style>
|
||||
<title>
|
||||
<xsl:for-each select="rdf:RDF/rss:channel">
|
||||
<xsl:value-of select="rss:description"/>
|
||||
</xsl:for-each>
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<xsl:for-each select="rdf:RDF/rss:image">
|
||||
<center><div class="image">
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:element name="img">
|
||||
<xsl:attribute name="src"><xsl:value-of select="rss:url"/></xsl:attribute>
|
||||
<xsl:attribute name="alt"><xsl:value-of select="rss:title"/></xsl:attribute>
|
||||
<xsl:attribute name="border">0</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</div></center>
|
||||
<center><div class="image-description">
|
||||
<xsl:value-of select="rss:description"/>
|
||||
</div></center>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:for-each select="rdf:RDF/rss:channel">
|
||||
<center><div class="channel-title">
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:value-of select="rss:title"/>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="dc:date"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
</xsl:element>
|
||||
</div></center>
|
||||
</xsl:for-each>
|
||||
|
||||
<ul>
|
||||
<hr />
|
||||
<xsl:for-each select="rdf:RDF/rss:item">
|
||||
<div class="item-title"><li>
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:value-of select="rss:title"/>
|
||||
</xsl:element>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="dc:date"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
</li></div>
|
||||
<div class="item-description"><xsl:value-of select="rss:description"/></div>
|
||||
<hr />
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
|
||||
<xsl:for-each select="rdf:RDF/rss:textinput">
|
||||
<center><b><div class="textinput-title"><xsl:value-of select="rss:description"/></div></b></center>
|
||||
<xsl:element name="form">
|
||||
<xsl:attribute name="action"><xsl:value-of select="rss:link"/></xsl:attribute>
|
||||
<xsl:attribute name="method">POST</xsl:attribute>
|
||||
<center><div class="textinput-form">
|
||||
<xsl:element name="input">
|
||||
<xsl:attribute name="name"><xsl:value-of select="rss:name"/></xsl:attribute>
|
||||
<xsl:attribute name="type">text</xsl:attribute>
|
||||
</xsl:element>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:element name="input">
|
||||
<xsl:attribute name="value"><xsl:value-of select="rss:title"/></xsl:attribute>
|
||||
<xsl:attribute name="type">submit</xsl:attribute>
|
||||
</xsl:element>
|
||||
</div></center>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
*
|
||||
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/TestSuite/Authors/ Authors/Developers
|
||||
* @package test_suite
|
||||
* @subpackage test_suite.suite_libs
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package test_suite
|
||||
* @subpackage test_suite.suite_libs
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class TestManager {
|
||||
var $_testExtension = '.test.php';
|
||||
var $_groupExtension = '.group.php';
|
||||
}
|
||||
?>
|
|
@ -10,9 +10,14 @@
|
|||
*
|
||||
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/>
|
||||
* Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
||||
*
|
||||
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||
* Portions modified from WACT Test Suite
|
||||
* Author(s): Harry Fuecks
|
||||
* Jon Ramsey
|
||||
* Jason E. Sweat
|
||||
* Franco Ponticelli
|
||||
* Lorenzo Alberton
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
|
@ -21,8 +26,7 @@
|
|||
* @author CakePHP Test Suite Authors/Developers
|
||||
* @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers
|
||||
* @link https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/Authors Authors/Developers
|
||||
* @package test_suite
|
||||
* @subpackage test_suite.tests_1_x
|
||||
* @package tests
|
||||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
|
@ -31,9 +35,12 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Path to the simpletest directory.
|
||||
* Path to the simpletest directory and unit tests.
|
||||
*/
|
||||
define ('SIMPLE_TEST',VENDORS.'simpletest'.DS);
|
||||
|
||||
define ('SIMPLE_TEST', VENDORS. 'simpletest'.DS);
|
||||
define ('CORE_TEST_CASES', TESTS. 'core' .DS. 'cases');
|
||||
define ('CORE_TEST_GROUPS', TESTS. 'core' .DS. 'groups');
|
||||
define ('APP_TEST_CASES', TESTS. 'app' .DS. 'cases');
|
||||
define ('APP_TEST_GROUPS', TESTS. 'app' .DS. 'groups');
|
||||
|
||||
?>
|
Loading…
Reference in a new issue