Author: Jan Borsodi
Date: 2006-12-20 11:37:16 +0100 (Wed, 20 Dec 2006)
New Revision: 4415
Log:
- Removed unused class ezcTemplateVariable and some useless test code.
Removed:
trunk/Template/src/variable.php
trunk/Template/tests/variable_test.php
Modified:
trunk/Template/src/template_autoload.php
trunk/Template/tests/template_test.php
Modified: trunk/Template/src/template_autoload.php
===================================================================
--- trunk/Template/src/template_autoload.php 2006-12-20 10:33:55 UTC (rev
4414)
+++ trunk/Template/src/template_autoload.php 2006-12-20 10:37:16 UTC (rev
4415)
@@ -15,7 +15,6 @@
"ezcTemplate" => "Template/template.php",
"ezcTemplateConfiguration" => "Template/configuration.php",
"ezcTemplateAutoloaderDefinition" =>
"Template/structs/autoloader_definition.php",
- "ezcTemplateVariable" => "Template/variable.php",
"ezcTemplateVariableCollection" =>
"Template/variable_collection.php",
"ezcTemplateLocation" => "Template/location.php",
Deleted: trunk/Template/src/variable.php
===================================================================
--- trunk/Template/src/variable.php 2006-12-20 10:33:55 UTC (rev 4414)
+++ trunk/Template/src/variable.php 2006-12-20 10:37:16 UTC (rev 4415)
@@ -1,96 +0,0 @@
-<?php
-/**
- * File containing the ezcTemplateVariable class
- *
- * @package Template
- * @version //autogen//
- * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
- * @license http://ez.no/licenses/new_bsd New BSD License
- * @access private
- */
-/**
- * Encapsulates the required data for a template variable.
- *
- * The variable is stored with a unique name, value and direction. In addition
it
- * can contain a type hint which may be used by the template to further
optimize
- * the code.
- *
- * @package Template
- * @version //autogen//
- * @access private
- */
-class ezcTemplateVariable
-{
-
- /**
- * Variable is passed from caller (PHP code or template code) to template
code.
- * @var int
- */
- const DIR_IN = 1;
-
- /**
- * Variable is passed from template code to caller (PHP code or template
code).
- * This means that template code can set this variable and it will be
readable by
- * PHP code after execution.
- * @var int
- */
- const DIR_OUT = 2;
-
- /**
- * Variable is not passed from one template to another but only contains a
value
- * for use ine one template.
- * @var int
- */
- const DIR_NONE = 3;
-
- /**
- * The name of the variable which must be a non-empty string.
- * @var string
- */
- public $name;
-
- /**
- * The value of the variable.
- *
- * Note: The null type cannot be used as value since it is used to
determine if
- * the variable is initialised or not.
- * @var mixed
- */
- public $value = null;
-
- /**
- * The class name or name of basic type the variable can contain. This can
be
- * used as type-hint for the template optimizer. If there is no specific
type it
- * must contain null.
- *
- * Note: A variable value of null is allowed for any given type.
- * @var string
- */
- public $type = null;
-
- /**
- * Controls passing direction of the variable, e.g. if it used as input
(DIR_IN),
- * output (DIR_OUT) or normal variable (DIR_NONE).
- * @var int
- */
- public $direction = self::DIR_NONE;
-
- /**
- * Initialises the properties from the parameters.
- *
- * @param string $name The name of the variable.
- * @param mixed $value The value for the variable.
- * @param string $type A type-hint for the variable which can be used by
the
- * optimizer.
- * @param int $direction The direction passing for the variable.
- */
- public function __construct( $name, $value = null, $type = null,
$direction = ezcTemplateVariable::DIR_NONE )
- {
- $this->name = $name;
- $this->value = $value;
- $this->type = $type;
- $this->direction = $direction;
- }
-
-}
-?>
Modified: trunk/Template/tests/template_test.php
===================================================================
--- trunk/Template/tests/template_test.php 2006-12-20 10:33:55 UTC (rev
4414)
+++ trunk/Template/tests/template_test.php 2006-12-20 10:37:16 UTC (rev
4415)
@@ -121,228 +121,6 @@
}
}
-
-
-
- /*
- public function testDefineInputVariable()
- {
- $template = new ezcTemplate();
-
- $template->defineInput( 'Garibaldi Michael', 'Jerry Doyle' );
-
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( true, $variables->hasVariable( 'Garibaldi Michael' ),
- "Defined input variable <Garibaldi Michael> does not
exist in variable collection for the manager." );
- $variable = $variables->getVariable( 'Garibaldi Michael' );
- self::assertSame( 'Garibaldi Michael', $variable->name,
- "Defined input variable does not have correct <name>
property." );
- self::assertSame( 'Jerry Doyle', $variable->value,
- "Defined input variable does not have correct
<value> property." );
- self::assertSame( null, $variable->type,
- "Defined input variable does not have correct <type>
property." );
- self::assertSame( ezcTemplateVariable::DIR_IN, $variable->direction,
- "Defined input variable does not have correct
<direction> property." );
- }
-
-
-
- public function testHasVariable()
- {
- $manager = new ezcTemplate();
-
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( false, $variables->hasVariable( 'Garibaldi Michael'
),
- "Defined input variable <Garibaldi Michael> exists
in variable collection for the manager." );
- self::assertSame( false, $manager->hasVariable( 'Garibaldi Michael' ),
- "Defined input variable <Garibaldi Michael> exists
in manager." );
-
-
- $manager->defineInput( 'Garibaldi Michael', 'Jerry Doyle' );
-
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( true, $variables->hasVariable( 'Garibaldi Michael' ),
- "Defined input variable <Garibaldi Michael> does not
exist in variable collection for the manager." );
- self::assertSame( true, $manager->hasVariable( 'Garibaldi Michael' ),
- "Defined input variable <Garibaldi Michael> does not
exist in manager." );
-
- $variable = $variables->getVariable( 'Garibaldi Michael' );
- self::assertSame( 'Garibaldi Michael', $variable->name,
- "Defined input variable does not have correct <name>
property." );
- self::assertSame( 'Jerry Doyle', $variable->value,
- "Defined input variable does not have correct
<value> property." );
- self::assertSame( null, $variable->type,
- "Defined input variable does not have correct <type>
property." );
- self::assertSame( ezcTemplateVariable::DIR_IN, $variable->direction,
- "Defined input variable does not have correct
<direction> property." );
- }
-
- public function testDefineOutputVariable()
- {
- $manager = new ezcTemplateManager();
-
- $manager->defineOutput( 'Garibaldi Michael' );
-
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( true, $variables->hasVariable( 'Garibaldi Michael' ),
- "Defined input variable <Garibaldi Michael> does not
exist in variable collection for the manager." );
- $variable = $variables->getVariable( 'Garibaldi Michael' );
- self::assertSame( 'Garibaldi Michael', $variable->name,
- "Defined input variable does not have correct <name>
property." );
- self::assertSame( null, $variable->value,
- "Defined input variable does not have correct
<value> property." );
- self::assertSame( null, $variable->type,
- "Defined input variable does not have correct <type>
property." );
- self::assertSame( ezcTemplateVariable::DIR_OUT, $variable->direction,
- "Defined input variable does not have correct
<direction> property." );
- }
-
- public function testRemoveVariable()
- {
- $manager = new ezcTemplateManager();
-
- $manager->defineInput( 'Garibaldi Michael', 'Jerry Doyle' );
- $manager->defineInput( 'Cotto Vir', 'Stephen Furst' );
- $manager->defineOutput( 'Alexander Lyta' );
-
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( true, $variables->hasVariable( 'Garibaldi Michael' ),
- "Defined input variable <Garibaldi Michael> does not
exist in variable collection for the manager." );
- self::assertSame( true, $variables->hasVariable( 'Cotto Vir' ),
- "Defined input variable <Cotto Vir> does not exist
in variable collection for the manager." );
- self::assertSame( true, $variables->hasVariable( 'Alexander Lyta' ),
- "Defined input variable <Alexander Lyta> does not
exist in variable collection for the manager." );
-
- $manager->removeVariable( 'Garibaldi Michael' );
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( false, $variables->hasVariable( 'Garibaldi Michael'
),
- "Removed input variable <Garibaldi Michael> still
exist in variable collection for the manager." );
- self::assertSame( true, $variables->hasVariable( 'Cotto Vir' ),
- "Defined input variable <Cotto Vir> does not exist
in variable collection for the manager." );
- self::assertSame( true, $variables->hasVariable( 'Alexander Lyta' ),
- "Defined input variable <Alexander Lyta> does not
exist in variable collection for the manager." );
- }
-
- public function testResetVariable()
- {
- $manager = new ezcTemplateManager();
-
- $manager->defineInput( 'Garibaldi Michael', 'Jerry Doyle' );
- $manager->defineInput( 'Cotto Vir', 'Stephen Furst' );
- $manager->defineOutput( 'Alexander Lyta' );
-
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( true, $variables->hasVariable( 'Garibaldi Michael' ),
- "Defined input variable <Garibaldi Michael> does not
exist in variable collection for the manager." );
- self::assertSame( true, $variables->hasVariable( 'Cotto Vir' ),
- "Defined input variable <Cotto Vir> does not exist
in variable collection for the manager." );
- self::assertSame( true, $variables->hasVariable( 'Alexander Lyta' ),
- "Defined input variable <Alexander Lyta> does not
exist in variable collection for the manager." );
-
- $manager->resetVariables();
- $managerArray = (array)$manager;
- $variables = $managerArray["\0ezcTemplateManager\0variables"];
- self::assertSame( false, $variables->hasVariable( 'Garibaldi Michael'
),
- "Removed input variable <Garibaldi Michael> still
exist in variable collection for the manager." );
- self::assertSame( false, $variables->hasVariable( 'Cotto Vir' ),
- "Removed input variable <Cotto Vir> does not exist
in variable collection for the manager." );
- self::assertSame( false, $variables->hasVariable( 'Alexander Lyta' ),
- "Removed input variable <Alexander Lyta> does not
exist in variable collection for the manager." );
- }
-*/
- /**
- * Check that the generateOptionHash() creates unique hashes. This is done
- * by going trough all possible combinations and creating the hashes, then
- * matching them against previous created. No duplicates should be found.
- */
- public function testUniqueOptionHash()
- {
- /*
- $manager = new ezcTemplateManager();
-
- // the possible values for each option
- $outputValues = array( false );
- $compiledValues = array( false );
-
- // all combinations with the property to modify
- $testValues = array( array( 'values' => $outputValues,
- 'property' => 'outputDebugEnabled' ),
- array( 'values' => $compiledValues,
- 'property' => 'compiledDebugEnabled' ) );
-
-
- self::assertTrue( count( $testValues ) > 0 );
-
- // Figure out total combinations possible
- $maxIterations = count( $testValues[0]['values'] );
- for ( $i = 1; $i < count( $testValues ); ++$i )
- {
- $count = count( $testValues[$i]['values'] );
- self::assertTrue( $count > 0 );
- $maxIterations *= $count;
- }
-
- $optionHashList = array();
-
- // Go trough all cominations by using iteration number for
- // index of each value list.
- for ( $i = 0; $i < $maxIterations; ++$i )
- {
- $tmp = $i;
- $testedValues = array();
- foreach ( $testValues as $testValue )
- {
- $count = count( $testValue['values'] );
- self::assertTrue( $count > 0 );
- $index = $tmp % $count;
- $tmp = (int)( $tmp / $count );
-
- self::assertTrue( isset( $manager->$testValue['property'] ) );
- $manager->$testValue['property'] =
$testValue['values'][$index];
-
- $testedValues[] = array( $testValue['property'] =>
$testValue['values'][$index] );
- }
- $hash = $manager->generateOptionHash();
- self::assertNotContains( $hash, $optionHashList,
- "The option hash <$hash> was found among
old values, used values <" . var_export( $testedValues, true ) . ">" );
- $optionHashList[] = $hash;
- }
- */
- }
-
-// public function testFindSource()
-// {
-// throw new PHPUnit_Framework_IncompleteTestError;
-// }
-
-// public function testFindCompiled()
-// {
-// throw new PHPUnit_Framework_IncompleteTestError;
-// }
-
- public function testProcess()
- {
- // $manager = new ezcTemplateManager();
- // $manager->configuration = new ezcTemplateConfiguration(
$this->templatePath, $this->templateCompiledPath );
-
- // $inputVariables = new ezcTemplateVariableCollection();
- // // $manager->setVariable( "a", 42 );
- // $result = $manager->process( $this->templatePath .
"ordinary_text.tpl" );
-
- // self::assertEquals ( $result->output, "Hello world\n");
-
- /*
- self::assertSame( 'ezcTemplateExecutionResult', get_class( $result ),
- 'ezcTemplateManager::process did not return valid
object' );
- */
- }
}
Deleted: trunk/Template/tests/variable_test.php
===================================================================
--- trunk/Template/tests/variable_test.php 2006-12-20 10:33:55 UTC (rev
4414)
+++ trunk/Template/tests/variable_test.php 2006-12-20 10:37:16 UTC (rev
4415)
@@ -1,49 +0,0 @@
-<?php
-/**
- * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
- * @license http://ez.no/licenses/new_bsd New BSD License
- * @version //autogentag//
- * @filesource
- * @package Template
- * @subpackage Tests
- */
-
-/**
- * @package Template
- * @subpackage Tests
- */
-class ezcTemplateVariableTest extends ezcTestCase
-{
- public static function suite()
- {
- return new PHPUnit_Framework_TestSuite( "ezcTemplateVariableTest" );
- }
-
- /**
- * Test default constructor values
- */
- public function testDefault()
- {
- $var = new ezcTemplateVariable( 'Sinclair Jeffrey' );
-
- self::assertSame( 'Sinclair Jeffrey', $var->name, 'Property <name>
does not return correct value.' );
- self::assertSame( null, $var->value, 'Property <value> does not return
correct value.' );
- self::assertSame( null, $var->type, 'Property <type> does not return
correct value.' );
- self::assertSame( ezcTemplateVariable::DIR_NONE, $var->direction,
'Property <direction> does not return correct value.' );
- }
-
- /**
- * Test passing constructor values
- */
- public function testInit()
- {
- $var = new ezcTemplateVariable( 'Sheridan John', 'Bruce Boxleitner',
'string', ezcTemplateVariable::DIR_IN );
-
- self::assertSame( 'Sheridan John', $var->name, 'Property <name> does
not return correct value.' );
- self::assertSame( 'Bruce Boxleitner', $var->value, 'Property <value>
does not return correct value.' );
- self::assertSame( 'string', $var->type, 'Property <type> does not
return correct value.' );
- self::assertSame( ezcTemplateVariable::DIR_IN, $var->direction,
'Property <direction> does not return correct value.' );
- }
-}
-
-?>
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components