From 943aa8849adda020461e551379422dfe59063c7f Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 24 Nov 2010 03:31:02 -0500 Subject: [PATCH] Add test groups for easier test breakdown. --- test/MustacheExceptionTest.php | 15 ++++++++++ test/MustacheObjectSectionTest.php | 3 ++ test/MustachePragmaDotNotationTest.php | 3 ++ test/MustachePragmaImplicitIteratorTest.php | 3 ++ test/MustachePragmaTest.php | 3 ++ test/MustachePragmaUnescapedTest.php | 3 ++ test/MustacheTest.php | 33 ++++++++++----------- 7 files changed, 45 insertions(+), 18 deletions(-) diff --git a/test/MustacheExceptionTest.php b/test/MustacheExceptionTest.php index 39a0f5b..a4e0787 100644 --- a/test/MustacheExceptionTest.php +++ b/test/MustacheExceptionTest.php @@ -15,6 +15,7 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase { } /** + * @group interpolation * @expectedException MustacheException */ public function testThrowsUnknownVariableException() { @@ -22,6 +23,7 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase { } /** + * @group sections * @expectedException MustacheException */ public function testThrowsUnclosedSectionException() { @@ -29,6 +31,7 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase { } /** + * @group sections * @expectedException MustacheException */ public function testThrowsUnexpectedCloseSectionException() { @@ -36,6 +39,7 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase { } /** + * @group partials * @expectedException MustacheException */ public function testThrowsUnknownPartialException() { @@ -43,25 +47,36 @@ class MustacheExceptionTest extends PHPUnit_Framework_TestCase { } /** + * @group pragmas * @expectedException MustacheException */ public function testThrowsUnknownPragmaException() { $this->pickyMustache->render('{{%SWEET-MUSTACHE-BRO}}'); } + /** + * @group sections + */ public function testDoesntThrowUnclosedSectionException() { $this->assertEquals('', $this->slackerMustache->render('{{#unclosed}}')); } + /** + * @group sections + */ public function testDoesntThrowUnexpectedCloseSectionException() { $this->assertEquals('', $this->slackerMustache->render('{{/unopened}}')); } + /** + * @group partials + */ public function testDoesntThrowUnknownPartialException() { $this->assertEquals('', $this->slackerMustache->render('{{>impartial}}')); } /** + * @group pragmas * @expectedException MustacheException */ public function testGetPragmaOptionsThrowsExceptionsIfItThinksYouHaveAPragmaButItTurnsOutYouDont() { diff --git a/test/MustacheObjectSectionTest.php b/test/MustacheObjectSectionTest.php index 17ad2e0..82405d6 100644 --- a/test/MustacheObjectSectionTest.php +++ b/test/MustacheObjectSectionTest.php @@ -2,6 +2,9 @@ require_once '../Mustache.php'; +/** + * @group sections + */ class MustacheObjectSectionTest extends PHPUnit_Framework_TestCase { public function testBasicObject() { $alpha = new Alpha(); diff --git a/test/MustachePragmaDotNotationTest.php b/test/MustachePragmaDotNotationTest.php index 488962b..56f6f11 100644 --- a/test/MustachePragmaDotNotationTest.php +++ b/test/MustachePragmaDotNotationTest.php @@ -2,6 +2,9 @@ require_once '../Mustache.php'; +/** + * @group pragmas + */ class MustachePragmaDotNotationTest extends PHPUnit_Framework_TestCase { public function testDotTraversal() { diff --git a/test/MustachePragmaImplicitIteratorTest.php b/test/MustachePragmaImplicitIteratorTest.php index 207a8c6..20fdcce 100644 --- a/test/MustachePragmaImplicitIteratorTest.php +++ b/test/MustachePragmaImplicitIteratorTest.php @@ -2,6 +2,9 @@ require_once '../Mustache.php'; +/** + * @group pragmas + */ class MustachePragmaImplicitIteratorTest extends PHPUnit_Framework_TestCase { public function testEnablePragma() { diff --git a/test/MustachePragmaTest.php b/test/MustachePragmaTest.php index 086e458..8be6e66 100644 --- a/test/MustachePragmaTest.php +++ b/test/MustachePragmaTest.php @@ -2,6 +2,9 @@ require_once '../Mustache.php'; +/** + * @group pragmas + */ class MustachePragmaTest extends PHPUnit_Framework_TestCase { public function testUnknownPragmaException() { diff --git a/test/MustachePragmaUnescapedTest.php b/test/MustachePragmaUnescapedTest.php index 8331312..df6d94c 100644 --- a/test/MustachePragmaUnescapedTest.php +++ b/test/MustachePragmaUnescapedTest.php @@ -2,6 +2,9 @@ require_once '../Mustache.php'; +/** + * @group pragmas + */ class MustachePragmaUnescapedTest extends PHPUnit_Framework_TestCase { public function testPragmaUnescaped() { diff --git a/test/MustacheTest.php b/test/MustacheTest.php index 7269b36..fba0327 100644 --- a/test/MustacheTest.php +++ b/test/MustacheTest.php @@ -132,8 +132,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase { /** * Test render() with data. * - * @access public - * @return void + * @group interpolation */ public function testRenderWithData() { $m = new Mustache('{{first_name}} {{last_name}}'); @@ -141,6 +140,9 @@ class MustacheTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Zappa, Frank', $m->render('{{last_name}}, {{first_name}}', array('first_name' => 'Frank', 'last_name' => 'Zappa'))); } + /** + * @group partials + */ public function testRenderWithPartials() { $m = new Mustache('{{>stache}}', null, array('stache' => '{{first_name}} {{last_name}}')); $this->assertEquals('Charlie Chaplin', $m->render(null, array('first_name' => 'Charlie', 'last_name' => 'Chaplin'))); @@ -150,8 +152,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase { /** * Mustache should allow newlines (and other whitespace) in comments and all other tags. * - * @access public - * @return void + * @group comments */ public function testNewlinesInComments() { $m = new Mustache("{{! comment \n \t still a comment... }}"); @@ -160,9 +161,6 @@ class MustacheTest extends PHPUnit_Framework_TestCase { /** * Mustache should return the same thing when invoked multiple times. - * - * @access public - * @return void */ public function testMultipleInvocations() { $m = new Mustache('x'); @@ -176,8 +174,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase { /** * Mustache should return the same thing when invoked multiple times. * - * @access public - * @return void + * @group interpolation */ public function testMultipleInvocationsWithTags() { $m = new Mustache('{{one}} {{two}}', array('one' => 'foo', 'two' => 'bar')); @@ -190,9 +187,6 @@ class MustacheTest extends PHPUnit_Framework_TestCase { /** * Mustache should not use templates passed to the render() method for subsequent invocations. - * - * @access public - * @return void */ public function testResetTemplateForMultipleInvocations() { $m = new Mustache('Sirve.'); @@ -205,15 +199,14 @@ class MustacheTest extends PHPUnit_Framework_TestCase { } /** - * testClone function. + * Test the __clone() magic function. * * @group examples * @dataProvider getExamples - * @access public + * * @param string $class * @param string $template * @param string $output - * @return void */ public function test__clone($class, $template, $output) { if (isset($this->knownIssues[$class])) { @@ -240,11 +233,10 @@ class MustacheTest extends PHPUnit_Framework_TestCase { * * @group examples * @dataProvider getExamples - * @access public + * * @param string $class * @param string $template * @param string $output - * @return void */ public function testExamples($class, $template, $output) { if (isset($this->knownIssues[$class])) { @@ -266,7 +258,6 @@ class MustacheTest extends PHPUnit_Framework_TestCase { * This whole mess will be refined later to be more intuitive and less prescriptive, but it'll * do for now. Especially since it means we can have unit tests :) * - * @access public * @return array */ public function getExamples() { @@ -317,6 +308,9 @@ class MustacheTest extends PHPUnit_Framework_TestCase { return $ret; } + /** + * @group delimiters + */ public function testCrazyDelimiters() { $m = new Mustache(null, array('result' => 'success')); $this->assertEquals('success', $m->render('{{=[[ ]]=}}[[ result ]]')); @@ -327,6 +321,9 @@ class MustacheTest extends PHPUnit_Framework_TestCase { $this->assertEquals('success', $m->render('{{=// \\\\}}// result \\\\')); } + /** + * @group delimiters + */ public function testResetDelimiters() { $m = new Mustache(null, array('result' => 'success')); $this->assertEquals('success', $m->render('{{=[[ ]]=}}[[ result ]]'));