Permalink
Browse files

Add tests for error class (incomplete)

  • Loading branch information...
1 parent 50bf349 commit a91ba343dd938816f441c0f49425fc23ced46e5c @stefanneculai committed Jul 2, 2012
View
2 code/bootstrap.php
@@ -38,7 +38,7 @@
define('JPATH_BASE', realpath(__DIR__));
}
-define('JPATH_SITE', JPATH_BASE . '/code');
+define('JPATH_SITE', realpath(__DIR__) . '/code');
define('JPATH_CACHE', JPATH_SITE . '/cache');
// Import the platform(s).
View
5 phpunit.xml.dist
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="tests/bootstrap.php" colors="false"
- stopOnFailure="true" testdox="true" verbose="true"
- backupStaticAttributes="false" backupGlobals="false">
+ stopOnFailure="false" testdox="true" verbose="true"
+ backupStaticAttributes="false" backupGlobals="false"
+ processIsolation="false">
<testsuite name="AllTests">
<directory>tests/unit</directory>
View
1 tests/bootstrap.php
@@ -25,7 +25,6 @@
// Import the platform.
require_once __DIR__ . '/../code/bootstrap.php';
-require_once __DIR__ . '/../code/application/web/errors.php';
// Register the core Joomla test classes.
JLoader::registerPrefix('Test', JPATH_PLATFORM . '/../tests/core');
View
18 tests/configs/default/config/content.dist.json
@@ -0,0 +1,18 @@
+{
+ "general":
+ {
+ "mandatory": "f1, f2, f3",
+ "optional": "f4, f5",
+ "map":
+ {
+ "id": "content_id",
+ "created_at": "created_date",
+ "user_id": "user_id",
+ "f1": "field1",
+ "f2": "field2",
+ "f3": "field3",
+ "f4": "field4",
+ "f5": "field5"
+ }
+ }
+}
View
17 tests/configs/default/config/errors.dist.json
@@ -0,0 +1,17 @@
+{
+ "301":
+ {
+ "code": "JWS001",
+ "message": "Message1",
+ "more_info": "",
+ "response_code": "400"
+ },
+
+ "302":
+ {
+ "code": "JWS002",
+ "message": "Message2",
+ "more_info": "",
+ "response_code": "400"
+ }
+}
View
63 tests/unit/application/web/errorsTest.php
@@ -298,7 +298,7 @@ public function testErrorsExist()
$this->assertEquals(false, $actual);
}
-/**
+ /**
* Tests getResponseCode()
*
* @return void
@@ -314,4 +314,65 @@ public function testGetResponseCode()
$this->assertEquals(100, $actual);
}
+
+ /**
+ * Seed data for fetchErrorsData()
+ *
+ * @return array
+ *
+ * @since 1.0
+ */
+ public function seedFetchErrorsData()
+ {
+ // JPATH_CONFIGURATION, JPATH_BASE, WEBSERVICE_CONFIG, Expected, Exception
+ return array(
+ array(null, JPATH_TESTS . '/configs/default', null, 2, null)
+ );
+ }
+
+ /**
+ * Tests fetchErrorsData()
+ *
+ * @param string $config The JPATH_CONFIGURATION string
+ * @param string $base The JPATH_BASE string
+ * @param string $wsconfig The WEBSERVICE_CONFIG string
+ * @param integer $expected The number of the expected errors from config file
+ * @param string $exception The exception
+ *
+ * @return void
+ *
+ * @covers WebServiceApplicationWebErrors::fetchErrorsData
+ * @dataProvider seedFetchErrorsData
+ * @since 1.0
+ */
+ public function testFetchErrorsData($config, $base, $wsconfig, $expected, $exception)
+ {
+ $this->markTestIncomplete('Have no idea how to change constants');
+ return;
+
+ if ($config != null)
+ {
+ define('JPATH_CONFIGURATION', $config);
+ }
+
+ if ($base != null)
+ {
+ define('JPATH_BASE', $base);
+ }
+
+ if ($wsconfig != null)
+ {
+ putenv('WEBSERVICE_CONFIG=' . $wsconfig);
+ }
+
+ if ($exception != null)
+ {
+ $this->setExpectedException($exception);
+ }
+
+ TestReflection::invoke($this->_instance, 'fetchErrorsData');
+
+ $actual = TestReflection::getValue($this->_instance, 'errorsMap');
+
+ }
}

0 comments on commit a91ba34

Please sign in to comment.