Permalink
Browse files

Add AllTests

Fix a bunch of errors with PHPUnit as well.
  • Loading branch information...
markstory committed Mar 29, 2012
1 parent 5c36e99 commit eeb44e070f40493ac71e875aa232bb981b3e15f0
View
@@ -120,11 +120,11 @@ public function getRules() {
*
* @param object $reflector Reflection Object to be inspected.
* @return boolean Success of setting source.
- * @throws Exception
+ * @throws RuntimeException
**/
public function setSource($reflector) {
if (!($reflector instanceof ClassDocumentor) && !($reflector instanceof FunctionDocumentor)) {
- throw new Exception(sprintf(
+ throw new RuntimeException(sprintf(
'DocBlockAnalyzer::setSource() - Expects an instance of ClassDocumentor or FunctionDocumentor, %s was given',
get_class($reflector)
));
@@ -427,4 +427,4 @@ public function score() {
}
return $good / $total;
}
-}
+}
View
@@ -322,7 +322,7 @@ function _unsetUnmatching(&$obj, $terms = array(), $field = 'properties') {
*
* @param array $apiClass An ApiClass record to be analyzed.
* @return array Array of warnings / info / % complete
- * @throws Exception Throws exception if you are looking at a non-concrete class, of if there
+ * @throws RuntimeException Throws exception if you are looking at a non-concrete class, of if there
* was an error with analyzation.
**/
public function analyzeCoverage($apiClass) {
@@ -339,7 +339,7 @@ public function analyzeCoverage($apiClass) {
$this->saveField('coverage_cache', $coverage['finalScore']);
return $coverage;
}
- throw new Exception(sprintf(
+ throw new RuntimeException(sprintf(
__d('api_generator', '%s is a pseudo class, and cannot have coverage generated'),
$apiClass['ApiClass']['name']
));
@@ -19,6 +19,7 @@
* @since ApiGenerator 0.1
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
**/
+App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
class ApiGeneratorAppModel extends AppModel {
@@ -55,4 +56,4 @@ protected function _makeSlug($name) {
return str_replace('_', '-', Inflector::underscore($name));
}
-}
+}
View
@@ -0,0 +1,15 @@
+<?php
+
+class AllTestsTest extends CakeTestSuite {
+/**
+ *
+ * @return PHPUnit_Framework_TestSuite the instance of PHPUnit_Framework_TestSuite
+ */
+ public static function suite() {
+ $path = dirname(__FILE__);
+ echo $path;
+ $suite = new CakeTestSuite('All ApiGenerator Tests.');
+ $suite->addTestDirectoryRecursive($path);
+ return $suite;
+ }
+}
@@ -62,6 +62,7 @@ function testConstruction() {
/**
* test that the source setting only allows Documentors.
*
+ * @expectedException RuntimeException
* @return void
**/
function testSourceSetting() {
@@ -70,7 +71,6 @@ function testSourceSetting() {
$result = $analyze->setSource($reflection);
$this->assertTrue($result);
- $this->expectException();
$fail = new StdClass();
$result = $analyze->setSource($fail);
$this->assertFalse($result);
@@ -8,11 +8,12 @@
class DocMarkdownTestCase extends CakeTestCase {
/**
- * start test
+ * setup
*
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$this->Parser = new DocMarkdown();
}
@@ -678,11 +679,12 @@ function testPropertyLinks() {
}
/**
- * end test
+ * tearDown
*
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Parser);
}
-}
+}
@@ -208,8 +208,8 @@ function testSearch() {
//test relevance in find
$result = $this->ApiClass->search('acl');
- $this->assertEqual(count($result), 2);
- $this->assertEqual(array_keys($result), array('AclComponent', 'IniAcl'));
+ $this->assertEqual(count($result), 1);
+ $this->assertEqual(array_keys($result), array('AclComponent'));
//test searching of global functions
$result = $this->ApiClass->search('debug');
@@ -258,6 +258,7 @@ function testGetClassIndex() {
/**
* Test that DocBlockAnalyzer is correctly invoked
*
+ * @expectedException RuntimeException
* @return void
**/
function testAnalyzeCoverage() {
@@ -274,10 +275,8 @@ function testAnalyzeCoverage() {
$this->assertTrue(is_numeric($apiClass['ApiClass']['coverage_cache']));
// try with pseudo class file.
- $this->expectException();
$apiClass = $this->ApiClass->read(null, '498cee77-97c8-441a-99c3-80ed87460ad7');
$result = $this->ApiClass->analyzeCoverage($apiClass);
- $this->assertFalse($result);
}
/**
@@ -45,20 +45,22 @@ classes = MyClass, MyOtherClass
class ApiConfigTestCase extends CakeTestCase {
/**
- * startTest
+ * setup
*
* @return void
**/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$this->ApiConfig = ClassRegistry::init('ApiGenerator.ApiConfig');
$this->ApiConfig->path = TMP . 'api_config.ini';
}
/**
- * endTest
+ * teardown
*
* @return void
**/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
$Cleanup = new File($this->ApiConfig->path);
$Cleanup->delete();
unset($this->ApiConfig);
@@ -126,14 +128,14 @@ function testRead() {
$result = $this->ApiConfig->read();
$this->assertEqual($result, array(
'paths' => array(
- '/home/cake/plugins/api_generator' => true
+ '/home/cake/plugins/api_generator' => 'true'
)
));
$result = $this->ApiConfig->read($data);
$this->assertEqual($result, array(
'paths' => array(
- '/home/cake/plugins/api_generator' => true
+ '/home/cake/plugins/api_generator' => 'true'
)
));
@@ -145,7 +147,7 @@ function testRead() {
$result = $this->ApiConfig->read();
$this->assertEqual($result, array(
'paths' => array(
- '/home/cake/plugins/api_generator' => true
+ '/home/cake/plugins/api_generator' => 'true'
)
));
@@ -154,7 +156,7 @@ function testRead() {
$result = $this->ApiConfig->read($data);
$this->assertEqual($result, array(
'paths' => array(
- '/Home/Cake/Plugins/Api_generator' => true
+ '/Home/Cake/Plugins/Api_generator' => 'true'
)
));
}
@@ -183,7 +185,7 @@ function testToString() {
function testSaveAndRead() {
$data = array(
'paths' => array(
- '/home/cake/plugins/api_generator' => true
+ '/home/cake/plugins/api_generator' => 'true'
),
'exclude' => array(
'properties' => 'private',
@@ -198,4 +200,4 @@ function testSaveAndRead() {
$result = $this->ApiConfig->read();
$this->assertEqual($result, $data);
}
-}
+}
@@ -277,7 +277,7 @@ function testIsAllowed() {
* @return void
*/
function testInitConfigNotNeedingSpaces() {
- $config =& ClassRegistry::init('ApiGenerator.ApiConfig');
+ $config = ClassRegistry::init('ApiGenerator.ApiConfig');
$config->data = array(
'exclude' => array(
'files' => 'one,two, three',
@@ -295,4 +295,4 @@ function testInitConfigNotNeedingSpaces() {
$this->assertEqual($file->excludeProperties, $expected);
$this->assertEqual($file->excludeDirectories, $expected);
}
-}
+}

0 comments on commit eeb44e0

Please sign in to comment.