123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
-
- require_once("simpletest/autorun.php");
- require_once("simpletest/web_tester.php");
- define(PENS_TEST_SERVER_URL, "http://localhost/pens/pens_server_test.php");
- define(PENS_TEST_RECEIPT_MAILTO, "mailto:test@test.com");
- class TestPENSServer extends WebTestCase {
-
- private $_valid_params = array(
- "command" => "collect",
- "pens-version" => "1.0.0",
- "package-type" => "aicc-pkg",
- "package-type-version" => "1.0",
- "package-format" => "zip",
- "package-id" => "http://myurl.com/12345",
- "package-url" => "http://www.aicc.org/pens/sample/captivatequiz.zip",
- "package-url-expiry" => "2099-04-09T14:17:43Z",
- "client" => "test-pens-server",
- "receipt" => PENS_TEST_RECEIPT_MAILTO);
-
- public function testEmptyQuery() {
- $this->get(PENS_TEST_SERVER_URL);
- $this->assertText("error=2002");
- }
-
- public function testValidQuery() {
- $this->get(PENS_TEST_SERVER_URL, $this->_valid_params);
- $this->assertText("error=0");
- }
-
- private function invalidParameterTest($name, $value, $error) {
- $params = $this->_valid_params;
- $params[$name] = $value;
- $this->get(PENS_TEST_SERVER_URL, $params);
- $this->assertText("error=".$error);
- }
-
- private function validParameterTest($name, $value) {
- $params = $this->_valid_params;
- $params[$name] = $value;
- $this->get(PENS_TEST_SERVER_URL, $params);
- $this->assertText("error=0");
- }
-
- public function testInvalidCommand() {
- $this->invalidParameterTest("command", "invalid", 2002);
- }
-
- public function testInvalidVersion() {
- $this->invalidParameterTest("pens-version", "0.8.0", 2001);
- }
-
- public function testInvalidPackageType() {
- $this->invalidParameterTest("package-type", "invalid", 2003);
- }
-
- public function testEmptyPackageTypeVersion() {
- $this->invalidParameterTest("package-type-version", null, 2004);
- }
-
- public function testInvalidPackageFormat() {
- $this->invalidParameterTest("package-format", "invalid", 2005);
- }
-
- public function testInvalidPackageId() {
- $this->invalidParameterTest("package-id", "invalid", 2007);
- }
-
- public function testInvalidPackageUrl() {
- $this->invalidParameterTest("package-url", "invalid", 2008);
- }
-
- public function testInvalidPackageUrlExpiry() {
- $this->invalidParameterTest("package-url-expiry", "invalid", 2009);
- }
-
- public function testValidPackageUrlExpiry() {
- $this->validParameterTest("package-url-expiry", "2099-01-01");
- }
-
- }
|