Author: as Date: Thu Nov 29 16:19:27 2007 New Revision: 6889 Log: - Added docblocks for tests. - Moved classes into separate files. # This was causing problems with running the tests alone.
Added: trunk/Debug/tests/formatters/html_formatter_data_structures.php (with props) trunk/Debug/tests/formatters/test_reporter.php (with props) trunk/Debug/tests/wrappers/ trunk/Debug/tests/wrappers/fake_wrapper.php (with props) Modified: trunk/Debug/tests/debug_test.php trunk/Debug/tests/debug_timer_test.php trunk/Debug/tests/formatters/html_formatter_test.php trunk/Debug/tests/suite.php trunk/Debug/tests/test_classes.php trunk/Debug/tests/writers/memory_writer_test.php Modified: trunk/Debug/tests/debug_test.php ============================================================================== --- trunk/Debug/tests/debug_test.php [iso-8859-1] (original) +++ trunk/Debug/tests/debug_test.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,5 +1,19 @@ <?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ +require_once 'test_classes.php'; + +/** + * @package Debug + * @subpackage Tests + */ class ezcDebugTest extends ezcTestCase { private $dbg; @@ -158,23 +172,4 @@ return new PHPUnit_Framework_TestSuite("ezcDebugTest"); } } - - -class TestReporter implements ezcDebugOutputFormatter -{ - public function generateOutput( array $timerData, array $writerData) - { - return array( $timerData, $writerData ); - } -} - -class MyFakeMapper implements ezcLogMapper -{ - public function get( $sev, $src, $cat ) - { - return null; - } - -} - ?> Modified: trunk/Debug/tests/debug_timer_test.php ============================================================================== --- trunk/Debug/tests/debug_timer_test.php [iso-8859-1] (original) +++ trunk/Debug/tests/debug_timer_test.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,9 +1,21 @@ <?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ +require_once 'test_classes.php'; +/** + * @package Debug + * @subpackage Tests + */ class ezcDebugTimerTest extends ezcTestCase { - public function testStartStop() { $timer = new ezcDebugTimer(); Added: trunk/Debug/tests/formatters/html_formatter_data_structures.php ============================================================================== --- trunk/Debug/tests/formatters/html_formatter_data_structures.php (added) +++ trunk/Debug/tests/formatters/html_formatter_data_structures.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,0 +1,83 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ + +/** + * Class used in the test suite. + * + * @package Debug + * @subpackage Tests + */ +class HtmlReporterDataStructures +{ + public function getLogStructure() + { + $log1 = new ezcDebugStructure(); + + $log1->message = "SELECT contentobject_id, login, email, password_hash, password_hash_type\n FROM ezuser\n WHERE contentobject_id='10'"; + $log1->source = "content"; + $log1->category = "sql"; + $log1->verbosity = 1; + $log1->datetime = "Oct 05 2005 12:04:20"; + + $log2 = new ezcDebugStructure(); + $log2->message = "SELECT DISTINCT ezdiscountrule.id\n FROM ezdiscountrule,\n ezuser_discountrule\n WHERE ezuser_discountrule.contentobject_id = '10' AND\n". + "ezuser_discountrule.discountrule_id = ezdiscountrule.id"; + $log2->source = "content"; + $log2->category = "sql"; + $log2->verbosity = 2; + $log2->datetime = "Oct 05 2005 12:04:25"; + + return array( $log1, $log2 ); + } + + public function getTimeStructure() + { + $time = new ezcDebugTimer(); + $time->startTimer("Script", "html_reporter_test", "script"); + + if ( true != false ) $i_do_something = false; + + $time->startTimer("Timing module", "content", "module"); + + if ( true != false ) $i_do_something = true; + + $this->mySQLFunction($time); + $this->mySQLFunction($time); + $this->mySQLFunction($time); + + $this->anotherMySQLFunction($time); + $this->anotherMySQLFunction($time); + + $time->stopTimer("Timing module"); + + $time->stopTimer("Script"); + + return $time->getTimeData(); + } + + protected function mySQLFunction(&$time) + { + $time->startTimer("my query", "html_reporter_test" , "query"); + + // My query.. + + $time->stopTimer("my query"); + } + + protected function anotherMySQLFunction(&$time) + { + $time->startTimer("replace mysql", "html_reporter_test" , "query"); + + // My query.. + + $time->stopTimer("replace mysql"); + } +} +?> Propchange: trunk/Debug/tests/formatters/html_formatter_data_structures.php ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/Debug/tests/formatters/html_formatter_test.php ============================================================================== --- trunk/Debug/tests/formatters/html_formatter_test.php [iso-8859-1] (original) +++ trunk/Debug/tests/formatters/html_formatter_test.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,12 +1,26 @@ <?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ +require_once 'Debug/tests/test_classes.php'; + +/** + * @package Debug + * @subpackage Tests + */ class ezcDebugHtmlFormatterTest extends ezcTestCase { public function testHtml() { $html = new ezcDebugHtmlFormatter(); - $struct = new HtmlReporterDatatructures(); + $struct = new HtmlReporterDataStructures(); $out = $html->generateOutput($struct->getLogStructure(), $struct->getTimeStructure()); @@ -23,76 +37,4 @@ return new PHPUnit_Framework_TestSuite(__CLASS__); } } - - -class HtmlReporterDatatructures -{ - - public function getLogStructure() - { - $log1 = new ezcDebugStructure(); - - $log1->message = "SELECT contentobject_id, login, email, password_hash, password_hash_type\n FROM ezuser\n WHERE contentobject_id='10'"; - $log1->source = "content"; - $log1->category = "sql"; - $log1->verbosity = 1; - $log1->datetime = "Oct 05 2005 12:04:20"; - - $log2 = new ezcDebugStructure(); - $log2->message = "SELECT DISTINCT ezdiscountrule.id\n FROM ezdiscountrule,\n ezuser_discountrule\n WHERE ezuser_discountrule.contentobject_id = '10' AND\n". - "ezuser_discountrule.discountrule_id = ezdiscountrule.id"; - $log2->source = "content"; - $log2->category = "sql"; - $log2->verbosity = 2; - $log2->datetime = "Oct 05 2005 12:04:25"; - - return array( $log1, $log2 ); - } - - - public function getTimeStructure() - { - $time = new ezcDebugTimer(); - $time->startTimer("Script", "html_reporter_test", "script"); - - if ( true != false ) $i_do_something = false; - - $time->startTimer("Timing module", "content", "module"); - - if ( true != false ) $i_do_something = true; - - $this->mySQLFunction($time); - $this->mySQLFunction($time); - $this->mySQLFunction($time); - - $this->anotherMySQLFunction($time); - $this->anotherMySQLFunction($time); - - $time->stopTimer("Timing module"); - - $time->stopTimer("Script"); - - return $time->getTimeData(); - } - - - protected function mySQLFunction(&$time) - { - $time->startTimer("my query", "html_reporter_test" , "query"); - - // My query.. - - $time->stopTimer("my query"); - } - - protected function anotherMySQLFunction(&$time) - { - $time->startTimer("replace mysql", "html_reporter_test" , "query"); - - // My query.. - - $time->stopTimer("replace mysql"); - } -} - ?> Added: trunk/Debug/tests/formatters/test_reporter.php ============================================================================== --- trunk/Debug/tests/formatters/test_reporter.php (added) +++ trunk/Debug/tests/formatters/test_reporter.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,0 +1,24 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ + +/** + * Test formatter used in the test suite. + * + * @package Debug + * @subpackage Tests + */ +class TestReporter implements ezcDebugOutputFormatter +{ + public function generateOutput( array $timerData, array $writerData ) + { + return array( $timerData, $writerData ); + } +} +?> Propchange: trunk/Debug/tests/formatters/test_reporter.php ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/Debug/tests/suite.php ============================================================================== --- trunk/Debug/tests/suite.php [iso-8859-1] (original) +++ trunk/Debug/tests/suite.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,17 +1,34 @@ <?php -require_once( "debug_delayed_init_test.php"); -require_once( "debug_test.php"); -require_once( "debug_timer_test.php"); -require_once( "writers/memory_writer_test.php"); -require_once( "formatters/html_formatter_test.php"); - +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ + +/** + * Including the tests + */ + +require_once "debug_delayed_init_test.php"; +require_once "debug_test.php"; +require_once "debug_timer_test.php"; +require_once "writers/memory_writer_test.php"; +require_once "formatters/html_formatter_test.php"; + +/** + * @package Debug + * @subpackage Tests + */ class ezcDebugSuite extends PHPUnit_Framework_TestSuite { public function __construct() { parent::__construct(); - $this->setName("Debug"); - + $this->setName( "Debug" ); + $this->addTest( ezcDebugDelayedInitTest::suite() ); $this->addTest( ezcDebugMemoryWriterTest::suite() ); $this->addTest( ezcDebugTimerTest::suite() ); @@ -24,5 +41,4 @@ return new ezcDebugSuite(); } } - ?> Modified: trunk/Debug/tests/test_classes.php ============================================================================== --- trunk/Debug/tests/test_classes.php [iso-8859-1] (original) +++ trunk/Debug/tests/test_classes.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,4 +1,27 @@ <?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ + +/** + * Include classes used in tests. + */ + +require_once 'formatters/html_formatter_data_structures.php'; +require_once 'formatters/test_reporter.php'; +require_once 'wrappers/fake_wrapper.php'; + +/** + * File included in all tests. + * + * @package Debug + * @subpackage Tests + */ class testDelayedInitDebug implements ezcBaseConfigurationInitializer { static function configureObject( $object ) Added: trunk/Debug/tests/wrappers/fake_wrapper.php ============================================================================== --- trunk/Debug/tests/wrappers/fake_wrapper.php (added) +++ trunk/Debug/tests/wrappers/fake_wrapper.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,0 +1,24 @@ +<?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ + +/** + * Wrapper used in the test suite. + * + * @package Debug + * @subpackage Tests + */ +class MyFakeMapper implements ezcLogMapper +{ + public function get( $sev, $src, $cat ) + { + return null; + } +} +?> Propchange: trunk/Debug/tests/wrappers/fake_wrapper.php ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/Debug/tests/writers/memory_writer_test.php ============================================================================== --- trunk/Debug/tests/writers/memory_writer_test.php [iso-8859-1] (original) +++ trunk/Debug/tests/writers/memory_writer_test.php [iso-8859-1] Thu Nov 29 16:19:27 2007 @@ -1,6 +1,17 @@ <?php +/** + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package Debug + * @subpackage Tests + */ - +/** + * @package Debug + * @subpackage Tests + */ class ezcDebugMemoryWriterTest extends ezcTestCase { protected function setUp() @@ -61,12 +72,9 @@ $this->assertEquals(count( $data ), 6); } - public static function suite() { - return new PHPUnit_Framework_TestSuite("ezcDebugMemoryWriterTest"); + return new PHPUnit_Framework_TestSuite( "ezcDebugMemoryWriterTest" ); } } - - ?> -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components