From c52baae3c88269b599571e88c911ad569f4bc4c1 Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Tue, 12 Mar 2013 15:32:46 +1300 Subject: [PATCH] Add some tests for the static parser --- .../manifest/ConfigStaticManifestTest.php | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 tests/core/manifest/ConfigStaticManifestTest.php diff --git a/tests/core/manifest/ConfigStaticManifestTest.php b/tests/core/manifest/ConfigStaticManifestTest.php new file mode 100644 index 000000000..fa8c49210 --- /dev/null +++ b/tests/core/manifest/ConfigStaticManifestTest.php @@ -0,0 +1,123 @@ +parse(); + } + + return $statics; + } + + public function testParsingAccessLevels() { + $statics = $this->parseSelf(); + + $levels = array( + 'nolevel' => null, + 'public' => T_PUBLIC, + 'public2' => T_PUBLIC, + 'protected' => T_PROTECTED, + 'protected2' => T_PROTECTED, + 'private' => T_PRIVATE, + 'private2' => T_PRIVATE + ); + + foreach($levels as $var => $level) { + $this->assertEquals( + $level, + $statics[__CLASS__][$var]['access'], + 'Variable '.$var.' has '.($level ? token_name($level) : 'no').' access level' + ); + } + } + + public function testParsingValues() { + $statics = $this->parseSelf(); + + // Check assigning values + $values = array( + 'none', + 'null', + 'int', + 'float', + 'string', + 'array', + ); + + $prepends = array( + 's', // Each on it's own + 'o', // All on one line + 'm' // All in on static statement, but each on own line + ); + + foreach ($values as $value) { + foreach ($prepends as $prepend) { + $var = "$prepend$value"; + + $this->assertEquals( + self::$$var, + $statics[__CLASS__][$var]['value'], + 'Variable '.$var.' value is extracted properly' + ); + } + } + } + + public function testIgnoresMethodStatics() { + $statics = $this->parseSelf(); + $this->assertNull(@$statics[__CLASS__]['method_static']); + } + + public function testIgnoresStaticMethods() { + $statics = $this->parseSelf(); + $this->assertNull(@$statics[__CLASS__]['static_method']); + } +} \ No newline at end of file