Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
* release/3.0.0:
  bump version from 2.1.0 to 3.0.0
  allow path to be specified when render is called
  • Loading branch information
yani- committed Aug 23, 2014
2 parents e6f4eb3 + 1897ecf commit abbe194
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage
.DS_Store
2 changes: 1 addition & 1 deletion examples/render-sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/
require_once
Expand Down
2 changes: 1 addition & 1 deletion examples/render-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/
require_once
Expand Down
2 changes: 1 addition & 1 deletion examples/views/common/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/
?>
Expand Down
2 changes: 1 addition & 1 deletion examples/views/users/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/
?>
Expand Down
20 changes: 13 additions & 7 deletions lib/Bandar.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/

Expand Down Expand Up @@ -120,14 +120,20 @@ public static function getTemplatesPathFromConstant()
*
* @return null
*/
public static function setTemplate($template)
public static function setTemplate($template, $path = false)
{
self::debug(
'Calling setTemplate with' . BANDAR_EOL .
'$template = ' . $template . BANDAR_EOL .
'type of $template is ' . gettype($template) . BANDAR_EOL
);
$template = self::getTemplatesPathFromConstant() . $template;

if ($path) {
$template = realpath($path) . DIRECTORY_SEPARATOR . $template;
} else {
$template = self::getTemplatesPathFromConstant() . $template;
}

$template = realpath($template . '.php');
/**
* Check if passed template exist
Expand Down Expand Up @@ -164,7 +170,7 @@ public static function templateExists($template)
*
* @return string Contents of the template
*/
public static function render($template, $args=array())
public static function render($template, $args=array(), $path = false)
{
self::debug(
'Calling render with' .
Expand All @@ -173,7 +179,7 @@ public static function render($template, $args=array())
'$args = ' . print_r($args, true) . BANDAR_EOL .
'type of $args is ' . gettype($args) . BANDAR_EOL
);
self::setTemplate($template);
self::setTemplate($template, $path);
/**
* Extracting passed aguments
*/
Expand All @@ -195,7 +201,7 @@ public static function render($template, $args=array())
*
* @return string Contents of the template
*/
public static function getTemplateContent($template, $args=array())
public static function getTemplateContent($template, $args=array(), $path = false)
{
self::debug(
'Calling render with' .
Expand All @@ -204,7 +210,7 @@ public static function getTemplateContent($template, $args=array())
'$args = ' . print_r($args, true) . BANDAR_EOL .
'type of $args is ' . gettype($args) . BANDAR_EOL
);
self::setTemplate($template);
self::setTemplate($template, $path);
/**
* Extracting passed aguments
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Exceptions/TemplateDoesNotExistException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/
require_once
Expand Down
35 changes: 35 additions & 0 deletions tests/templates-2/users-2/list-2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* Template view used in Bandar engine unit tests
*
* PHP version 5
*
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @category Tests
* @package Bandar_Views
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/
?>
2. Hello <?php echo $name; ?>
4 changes: 2 additions & 2 deletions tests/templates/users/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/
?>
Hello <?php echo $name; ?>
1. Hello <?php echo $name; ?>
6 changes: 3 additions & 3 deletions tests/test-bandar-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/

Expand All @@ -41,7 +41,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version Release: 2.1.0
* @version Release: 3.0.0
* @link https://github.com/yani-/bandar/
*/
class BandarTestContent extends PHPUnit_Framework_TestCase
Expand All @@ -64,7 +64,7 @@ public function testGetTemplateContent()
array('name' => 'John Smith')
);
$this->assertEquals(
'Hello John Smith',
'1. Hello John Smith',
$content
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test-bandar-debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/

Expand All @@ -41,7 +41,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version Release: 2.1.0
* @version Release: 3.0.0
* @link https://github.com/yani-/bandar/
*/
class BandarTestDebug extends PHPUnit_Framework_TestCase
Expand Down
86 changes: 86 additions & 0 deletions tests/test-bandar-mutliple-sources.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* Provides unit tests for Bandar template engine
*
* PHP version 5
*
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @category Tests
* @package Bandar_Tests
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/

/**
* Unit test class
*
* @category Tests
* @package Bandar_Tests
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version Release: 3.0.0
* @link https://github.com/yani-/bandar/
*/
class BandarTestMultipleSources extends PHPUnit_Framework_TestCase
{
/**
* [testGetTemplateContent description]
*
* @runInSeparateProcess
*
* @return void
*/
public function testMutipleSources()
{
define(
'BANDAR_TEMPLATES_PATH',
dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates'
);
ob_start();
Bandar::render(
'users-2/list-2',
array('name' => 'John Smith'),
dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates-2'
);
$renderedContent = ob_get_clean();
$this->assertEquals(
'2. Hello John Smith',
$renderedContent
);

ob_start();
Bandar::render(
'users/list',
array('name' => 'John Smith')
);
$renderedContent = ob_get_clean();
$this->assertEquals(
'1. Hello John Smith',
$renderedContent
);
}
}

6 changes: 3 additions & 3 deletions tests/test-bandar-render.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/

Expand All @@ -41,7 +41,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version Release: 2.1.0
* @version Release: 3.0.0
* @link https://github.com/yani-/bandar/
*/
class BandarTestRender extends PHPUnit_Framework_TestCase
Expand All @@ -66,7 +66,7 @@ public function testRender()
);
$renderedContent = ob_get_clean();
$this->assertEquals(
'Hello John Smith',
'1. Hello John Smith',
$renderedContent
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test-bandar.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version GIT: 2.1.0
* @version GIT: 3.0.0
* @link https://github.com/yani-/bandar/
*/

Expand All @@ -41,7 +41,7 @@
* @author Yani Iliev <[email protected]>
* @copyright 2013 Yani Iliev
* @license https://raw.github.com/yani-/bandar/master/LICENSE The MIT License (MIT)
* @version Release: 2.1.0
* @version Release: 3.0.0
* @link https://github.com/yani-/bandar/
*/
class BandarTest extends PHPUnit_Framework_TestCase
Expand Down

0 comments on commit abbe194

Please sign in to comment.