Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

Commit

Permalink
Merge branch '2.1' into compiler_algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxist committed Sep 1, 2010
2 parents f31061a + 4d4b42e commit c3bfd8d
Show file tree
Hide file tree
Showing 234 changed files with 1,602 additions and 733 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/paths.ini
24 changes: 24 additions & 0 deletions LICENSE
@@ -0,0 +1,24 @@
Copyright (c) 2008-2010, Invenzzia Group <http://www.invenzzia.org/>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Invenzzia Group nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY INVENZZIA GROUP AND OTHER CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL INVENZZIA GROUP BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
451 changes: 451 additions & 0 deletions LICENSE.DOCS

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/output/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 1 addition & 1 deletion lib/Opt/Function.php
Expand Up @@ -640,7 +640,7 @@ static public function entity($name)
{
if(!preg_match('/^(([a-zA-Z\_\:]{1}[a-zA-Z0-9\_\:\-\.]*)|(\#((x[a-fA-F0-9]+)|([0-9]+))))$/', $name))
{
throw new Opt_InvalidEntityName_Exception($name);
throw new Opt_Exception('Invalid entity name: '.$name);
}
return '&'.$name.';';
} // end entity();
Expand Down
2 changes: 1 addition & 1 deletion lib/Opt/Instruction/Component.php
Expand Up @@ -315,7 +315,7 @@ private function _commonProcessing(Opt_Xml_Element $node, $componentVariable, ar
// Scan for opt:set tags - they may contain some custom arguments.
$set2 = $node->getElementsByTagNameNS('opt', 'set');

// Now a little trick - how to cheat the opt:insert instruction
// Now a little trick - how to cheat the opt:use instruction
$useAttribute = new Opt_Xml_Attribute('opt:use', $params['template']);
$this->_compiler->processor('snippet')->processAttribute($node, $useAttribute);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Opt/Parser/Html.php
Expand Up @@ -502,8 +502,9 @@ protected function _compileAttributes($attrList)
// stored without the entities.
if(isset($result[$name]))
{
// TODO: Instead of $result{$name] we should show tag name!
throw new Opt_Parser_Exception(
'XML Error: duplicated attribute '.$name.' in '.$tagName.'.',
'XML Error: duplicated attribute '.$name.' in '.$result[$name].'.',
'HTML',
$this->_filename
);
Expand Down
4 changes: 2 additions & 2 deletions tests/Package/ClassTest.php
Expand Up @@ -122,7 +122,7 @@ public function testRegisterIsLockedAfterInit()

$this->_tpl->register(Opt_Class::PHP_CLASS, 'foo', 'bar');
}
catch(Opt_Initialization_Exception $exception)
catch(Opt_Exception $exception)
{
return true;
}
Expand Down Expand Up @@ -280,4 +280,4 @@ public function testCacheReset()
return true;
} // end testCacheReset();

} // end Package_ClassTest;
} // end Package_ClassTest;
2 changes: 1 addition & 1 deletion tests/Package/Expression/StandardTest.php
Expand Up @@ -260,4 +260,4 @@ public function testExpression($assign, $src, $dst, $result)
$this->fail('Exception returned: #'.get_class($e).': '.$e->getMessage().' (line: '.$e->getLine().')');
}
} // end testExpression();
} // end Package_Instruction_InstructionTest;
} // end Package_Instruction_InstructionTest;
22 changes: 11 additions & 11 deletions tests/Package/Inflector/StandardTest.php
Expand Up @@ -50,7 +50,7 @@ public function testConstructorReadsStreamsFromConfig()

/**
* @covers Opt_Inflector_Standard::__construct
* @expectedException Opt_InvalidOptionValue_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testConstructorShouldThrowException()
{
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testAddStreamWithoutObfuscation()

/**
* @covers Opt_Inflector_Standard::addStream
* @expectedException Opt_ObjectExists_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testAddExistingStream()
{
Expand All @@ -115,7 +115,7 @@ public function testAddExistingStream()

/**
* @covers Opt_Inflector_Standard::getStream
* @expectedException Opt_ObjectNotExists_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testGetStreamThrowsException()
{
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testRemoveStreamRemoves()

/**
* @covers Opt_Inflector_Standard::removeStream
* @expectedException Opt_ObjectNotExists_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testRemoveStreamThrowsException()
{
Expand All @@ -169,7 +169,7 @@ public function testGetSourcePathReturnsDefaultStreamPath()

/**
* @covers Opt_Inflector_Standard::getSourcePath
* @expectedException Opt_NotSupported_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testGetSourcePathDoesNotAllowRelativePathsDefault()
{
Expand All @@ -183,7 +183,7 @@ public function testGetSourcePathDoesNotAllowRelativePathsDefault()

/**
* @covers Opt_Inflector_Standard::getSourcePath
* @expectedException Opt_ObjectNotExists_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testGetSourcePathDefaultStreamMissing()
{
Expand Down Expand Up @@ -224,7 +224,7 @@ public function testGetSourcePathReturnsStreamPath()

/**
* @covers Opt_Inflector_Standard::getSourcePath
* @expectedException Opt_NotSupported_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testGetSourcePathDoesNotAllowRelativePaths()
{
Expand All @@ -239,7 +239,7 @@ public function testGetSourcePathDoesNotAllowRelativePaths()

/**
* @covers Opt_Inflector_Standard::getSourcePath
* @expectedException Opt_ObjectNotExists_Exception
* @expectedException Opt_Inflector_Exception
*/
public function testGetSourcePathStreamMissing()
{
Expand Down Expand Up @@ -275,7 +275,7 @@ public function testGetCompiledPathReplacesDangerousSymbols()
$mock->stdStream = 'file';
$inflector = new Opt_Inflector_Standard($mock);

$this->assertEquals('test__a__b__c.tpl.php', $inflector->getCompiledPath('test/a:b\\c.tpl', array()));
$this->assertEquals('test_a_b_c.tpl.php', $inflector->getCompiledPath('test/a:b\\c.tpl', array()));
} // end testGetCompiledPathReplacesDangerousSymbols();

/**
Expand All @@ -289,7 +289,7 @@ public function testGetCompiledPathPrependsCompileId()
$mock->compileId = 'foo';
$inflector = new Opt_Inflector_Standard($mock);

$this->assertEquals('foo_test__a__b__c.tpl.php', $inflector->getCompiledPath('test/a:b\\c.tpl', array()));
$this->assertEquals('foo_test_a_b_c.tpl.php', $inflector->getCompiledPath('test/a:b\\c.tpl', array()));
} // end testGetCompiledPathPrependsCompileId();

/**
Expand All @@ -302,6 +302,6 @@ public function testGetCompiledPathBuildsPathForInheritance()
$mock->stdStream = 'file';
$inflector = new Opt_Inflector_Standard($mock);

$this->assertEquals('bar.tpl/foo.tpl/test__a__b__c.tpl.php', $inflector->getCompiledPath('test/a:b\\c.tpl', array('foo.tpl', 'bar.tpl')));
$this->assertEquals('bar.tpl/foo.tpl/test_a_b_c.tpl.php', $inflector->getCompiledPath('test/a:b\\c.tpl', array('foo.tpl', 'bar.tpl')));
} // end testGetCompiledPathBuildsPathForInheritance();
} // end Package_Inflector_StandardTest;
63 changes: 60 additions & 3 deletions tests/Package/Instruction/AllTests.php
@@ -1,13 +1,42 @@
<?php
/**
* The test suite file that configures the execution of the test cases for instructions.
* The test suite file that configures the execution of the test cases for
* instructions.
*
* @author Tomasz "Zyx" Jędrzejewski
* @copyright Copyright (c) 2009 Invenzzia Group
* @license http://www.invenzzia.org/license/new-bsd New BSD License
*/

require_once('InstructionTest.php');
//require_once('AttributeTest.php');
//require_once('AttributesBuildTest.php');
require_once('BlockTest.php');
//require_once('CaptureTest.php');
require_once('ComponentTest.php');
require_once('ContentTest.php');
require_once('DtdTest.php');
require_once('ExtendTest.php');
//require_once('ForTest.php');
//require_once('ForeachTest.php');
//require_once('GridTest.php');
require_once('IfTest.php');
require_once('IncludeTest.php');
//require_once('InsertTest.php');
//require_once('LiteralTest.php');
require_once('OmitTagTest.php');
require_once('ProcedureTest.php');
require_once('PrologTest.php');
//require_once('PutTest.php');
require_once('RepeatTest.php');
//require_once('RootTest.php');
require_once('SectionTest.php');
//require_once('SelectorTest.php');
//require_once('ShowTest.php');
//require_once('SingleTest.php');
require_once('SnippetTest.php');
require_once('SwitchTest.php');
//require_once('TagTest.php');
require_once('TreeTest.php');

class Package_Instruction_AllTests extends PHPUnit_Framework_TestSuite
{
Expand All @@ -20,7 +49,35 @@ class Package_Instruction_AllTests extends PHPUnit_Framework_TestSuite
public static function suite()
{
$suite = new Package_Instruction_AllTests('Package_Instruction');
$suite->addTestSuite('Package_Instruction_InstructionTest');
//$suite->addTestSuite('Package_Instruction_AttributeTest');
//$suite->addTestSuite('Package_Instruction_AttributesBuildTest');
$suite->addTestSuite('Package_Instruction_BlockTest');
//$suite->addTestSuite('Package_Instruction_CaptureTest');
$suite->addTestSuite('Package_Instruction_ComponentTest');
$suite->addTestSuite('Package_Instruction_ContentTest');
$suite->addTestSuite('Package_Instruction_DtdTest');
$suite->addTestSuite('Package_Instruction_ExtendTest');
//$suite->addTestSuite('Package_Instruction_ForTest');
//$suite->addTestSuite('Package_Instruction_ForeachTest');
//$suite->addTestSuite('Package_Instruction_GridTest');
$suite->addTestSuite('Package_Instruction_IfTest');
$suite->addTestSuite('Package_Instruction_IncludeTest');
//$suite->addTestSuite('Package_Instruction_InsertTest');
//$suite->addTestSuite('Package_Instruction_LiteralTest');
$suite->addTestSuite('Package_Instruction_OmitTagTest');
$suite->addTestSuite('Package_Instruction_ProcedureTest');
$suite->addTestSuite('Package_Instruction_PrologTest');
//$suite->addTestSuite('Package_Instruction_PutTest');
$suite->addTestSuite('Package_Instruction_RepeatTest');
//$suite->addTestSuite('Package_Instruction_RootTest');
$suite->addTestSuite('Package_Instruction_SectionTest');
//$suite->addTestSuite('Package_Instruction_SelectorTest');
//$suite->addTestSuite('Package_Instruction_ShowTest');
//$suite->addTestSuite('Package_Instruction_SingleTest');
$suite->addTestSuite('Package_Instruction_SnippetTest');
$suite->addTestSuite('Package_Instruction_SwitchTest');
//$suite->addTestSuite('Package_Instruction_TagTest');
$suite->addTestSuite('Package_Instruction_TreeTest');

return $suite;
} // end suite();
Expand Down
59 changes: 59 additions & 0 deletions tests/Package/Instruction/BlockTest.php
@@ -0,0 +1,59 @@
<?php
/**
* The tests for opt:block instruction.
*
* @author Tomasz "Zyx" Jędrzejewski
* @copyright Copyright (c) 2009 Invenzzia Group
* @license http://www.invenzzia.org/license/new-bsd New BSD License
*/

require_once('./Extra/TestFS.php');
require_once('./Extra/TestFSBase.php');

/**
* @covers Opt_Compiler_Class
* @covers Opt_Compiler_Format
* @covers Opt_Compiler_Processor
* @covers Opt_Instruction_Block
* @runTestsInSeparateProcesses
*/
class Package_Instruction_BlockTest extends Extra_TestFSBase
{

/**
* Configuration method.
* @param Opt_Class $tpl
*/
public function configure(Opt_Class $tpl)
{
$tpl->parser = 'Opt_Parser_Xml';
$tpl->register(Opt_Class::OPT_COMPONENT, 'opt:myComponent', 'Extra_Mock_Component');
$tpl->register(Opt_Class::OPT_BLOCK, 'opt:myBlock', 'Extra_Mock_Block');
} // end configure();

/**
* Provides the list of test cases.
* @return Array
*/
public static function dataProvider()
{
return array(0 =>
array('Block/block_basic.txt'),
array('Block/block_single.txt'),
array('Block/block_arguments.txt'),
array('Block/block_single_args.txt'),
array('Block/block_static.txt'),
array('Block/block_empty.txt'),
array('Block/block_nesting.txt'),
);
} // end dataProvider();

/**
* @dataProvider dataProvider
* @runInSeparateProcess
*/
public function testInstructions($testCase)
{
return $this->_checkTest(dirname(__FILE__).'/Tests/'.$testCase);
} // end testInstructions();
} // end Package_Instruction_BlockTest;
65 changes: 65 additions & 0 deletions tests/Package/Instruction/ComponentTest.php
@@ -0,0 +1,65 @@
<?php
/**
* The tests for opt:component instruction.
*
* @author Tomasz "Zyx" Jędrzejewski
* @copyright Copyright (c) 2009 Invenzzia Group
* @license http://www.invenzzia.org/license/new-bsd New BSD License
*/

require_once('./Extra/TestFS.php');
require_once('./Extra/TestFSBase.php');

/**
* @covers Opt_Compiler_Class
* @covers Opt_Compiler_Format
* @covers Opt_Compiler_Processor
* @covers Opt_Instruction_Component
* @runTestsInSeparateProcesses
*/
class Package_Instruction_ComponentTest extends Extra_TestFSBase
{

/**
* Configuration method.
* @param Opt_Class $tpl
*/
public function configure(Opt_Class $tpl)
{
$tpl->parser = 'Opt_Parser_Xml';
$tpl->register(Opt_Class::OPT_COMPONENT, 'opt:myComponent', 'Extra_Mock_Component');
$tpl->register(Opt_Class::OPT_BLOCK, 'opt:myBlock', 'Extra_Mock_Block');
} // end configure();

/**
* Provides the list of test cases.
* @return Array
*/
public static function dataProvider()
{
return array(0 =>
array('Component/component_basic.txt'),
array('Component/component_datasource.txt'),
array('Component/component_display.txt'),
array('Component/component_display_attr.txt'),
array('Component/component_events.txt'),
array('Component/component_management.txt'),
array('Component/component_multiple.txt'),
array('Component/component_defined.txt'),
array('Component/component_param_empty.txt'),
array('Component/component_skipping_opt.txt'),
array('Component/component_inject_procedure.txt'),
array('Component/component_inject_snippet.txt'),
array('Component/component_nesting.txt'),
);
} // end dataProvider();

/**
* @dataProvider dataProvider
* @runInSeparateProcess
*/
public function testInstructions($testCase)
{
return $this->_checkTest(dirname(__FILE__).'/Tests/'.$testCase);
} // end testInstructions();
} // end Package_Instruction_ComponentTest;

0 comments on commit c3bfd8d

Please sign in to comment.