Skip to content
This repository has been archived by the owner on Feb 20, 2018. It is now read-only.

Commit

Permalink
added some more tests to twig
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodip committed May 26, 2011
1 parent b1f5c5c commit 4983bdc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Mandango/Mondator/ClassExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,7 @@ public function getTwig()
throw new \RuntimeException('Twig is required to use templates.');
}

$templateDirs = array();
$ref = new \ReflectionClass($this);
$templateDirs = dirname($ref->getFileName()).'/templates';

$loader = new \Twig_Loader_Filesystem($templateDirs);
$loader = new \Twig_Loader_String();
$twig = new \Twig_Environment($loader, array(
'autoescape' => false,
'strict_variables' => true,
Expand Down
9 changes: 9 additions & 0 deletions tests/Mandango/Mondator/Tests/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ public function testTwigSupport()
$this->assertTrue($article->hasPropertyByName('staticProperty'));
$this->assertTrue($article->getPropertyByName('staticProperty')->isStatic());

$this->assertTrue($article->hasPropertyByName('anotherPublicProperty'));
$this->assertSame('public', $article->getPropertyByName('anotherPublicProperty')->getVisibility());

$this->assertTrue($article->hasPropertyByName('anotherProtectedProperty'));
$this->assertSame('protected', $article->getPropertyByName('anotherProtectedProperty')->getVisibility());

$this->assertTrue($article->hasPropertyByName('anotherPrivateProperty'));
$this->assertSame('private', $article->getPropertyByName('anotherPrivateProperty')->getVisibility());

// methods
$this->assertTrue($article->hasMethodByName('publicMethod'));
$this->assertSame('public', $article->getMethodbyName('publicMethod')->getVisibility());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ protected function doClassProcess()
{
$this->definitions['document'] = new Definition($this->class, new Output(sys_get_temp_dir()));

$this->processTemplate($this->definitions['document'], 'defining.php');
$this->processTemplate($this->definitions['document'], file_get_contents(__DIR__.'/templates/defining.php'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
private $privateProperty;
static public $staticProperty;

public $anotherPublicProperty;

protected $anotherProtectedProperty;

private $anotherPrivateProperty;

static protected $anotherPublicProperty;

public function publicMethod()
{
}
Expand Down

0 comments on commit 4983bdc

Please sign in to comment.