Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/tests
diff options
context:
space:
mode:
Diffstat (limited to 'site/app/tests')
-rw-r--r--site/app/tests/controllers/users_controller.test.php8
-rw-r--r--site/app/tests/languageConfig.test.php16
-rw-r--r--site/app/tests/services/update.test.php17
-rw-r--r--site/app/tests/test_helper_unit.php2
-rw-r--r--site/app/tests/test_helper_web.php32
-rw-r--r--site/app/tests/test_manager.php12
6 files changed, 62 insertions, 25 deletions
diff --git a/site/app/tests/controllers/users_controller.test.php b/site/app/tests/controllers/users_controller.test.php
index a28daf5..c81ebb6 100644
--- a/site/app/tests/controllers/users_controller.test.php
+++ b/site/app/tests/controllers/users_controller.test.php
@@ -73,7 +73,13 @@ class UsersTest extends UnitTestCase {
$this->controller = $this->helper->getController('Users', $this);
$this->helper->mockComponents($this->controller, $this);
$this->controller->User->cacheQueries = false; // important! Otherwise cake doesn't realize when we changed the user data.
- $this->controller->User->caching = false; // improtant! Otherwise memcache will break stuff.
+ $this->controller->User->caching = false; // important! Otherwise memcache will break stuff.
+
+ // Prevent exceptions in other parts of the world.
+ $this->controller->Amo->setReturnValue('getApplicationVersions',
+ array(1 => array(1.5, 2.0, 3.0),
+ 18 => array(1.5, 2.0, 3.0)));
+ $this->controller->params['url'] = array();
}
/**
diff --git a/site/app/tests/languageConfig.test.php b/site/app/tests/languageConfig.test.php
index a9d87c1..56fe679 100644
--- a/site/app/tests/languageConfig.test.php
+++ b/site/app/tests/languageConfig.test.php
@@ -100,6 +100,22 @@ class LanguageConfigTest extends WebTestHelper {
}
/**
+ * Our msgids should conform to the AMO L10n standards. Details at
+ * https://wiki.mozilla.org/Update:Remora_Localization#L10n_standards
+ *
+ * We'll only check en-US here, but the others are built off en-US so it should be a good indicator.
+ */
+ function testLangFileIsValid() {
+ $_language_file = "{$this->language_config->text_domain}/en_US/LC_MESSAGES/messages.po";
+
+ $_language_file_contents = file_get_contents($_language_file);
+
+ // If this test fails there is a string with spaces in it which is most likely an English string or
+ // sentence. This should be fixed before merging en-US -> all locales
+ $this->assertEqual(preg_match('/^msgid\ ".*?\ .*?"$/m', $_language_file_contents), 0);
+ }
+
+ /**
* Checks and makes sure index pages will load with all valid languages
*/
function testLocalizedPagesLoad()
diff --git a/site/app/tests/services/update.test.php b/site/app/tests/services/update.test.php
index 5209233..edd3957 100644
--- a/site/app/tests/services/update.test.php
+++ b/site/app/tests/services/update.test.php
@@ -60,7 +60,7 @@
// Require update function file.
require_once(APP.'webroot/services/functions.php');
-class UpdateServiceTest extends WebTestCase {
+class UpdateServiceTest extends WebTestHelper {
var $_args;
var $_noUpdatesXml;
@@ -105,24 +105,13 @@ NoUpdateXml;
}
/**
- * Build an update URI based on _args.
- * @param array $args update URI arguments
- * @return string resulting URI
- */
- function _buildUpdateUri($args=array()) {
- $_buf = array();
- foreach ($args as $key=>$val) {
- $_buf[] = $key.'='.$val;
- }
- return SERVICE_URL.'/update.php?test=1&'.implode('&',$_buf);
- }
-
- /**
* Retrieve XML document based on _args.
* @param array $args update URI arguments
* @return string resulting XML document as a string
*/
function _getXml($args=array()) {
+ // Use the test db.
+ $args['test'] = 1;
return $this->get(SERVICE_URL.'/update.php',$args);
}
diff --git a/site/app/tests/test_helper_unit.php b/site/app/tests/test_helper_unit.php
index 49903a5..f88f691 100644
--- a/site/app/tests/test_helper_unit.php
+++ b/site/app/tests/test_helper_unit.php
@@ -193,7 +193,7 @@ class UnitTestHelper
* Since there is nothing we can do to prevent those, we are going to filter them
* out and add the $realErrors back into the queue later on.
*/
- $queue = &SimpleErrorQueue::instance();
+ $queue = &SimpleTest::getContext()->get('SimpleErrorQueue');
$realErrors = array();
while ($error = $queue->extract())
diff --git a/site/app/tests/test_helper_web.php b/site/app/tests/test_helper_web.php
index 9b2211e..9791a71 100644
--- a/site/app/tests/test_helper_web.php
+++ b/site/app/tests/test_helper_web.php
@@ -1,6 +1,13 @@
<?php
class WebTestHelper extends WebTestCase {
+
+ function before($method) {
+ // The test browser is created in parent::before.
+ parent::before($method);
+ $this->addHeader('X-Amo-Test: damn right');
+ }
+
/* Compute protocol and hostname prefix, no trailing slash. */
function hostPrefix() {
$http = (!empty($_SERVER["HTTP_MOZ_REQ_METHOD"]) && $_SERVER["HTTP_MOZ_REQ_METHOD"] == 'HTTPS') ? 'https://' : 'http://';
@@ -8,6 +15,15 @@ class WebTestHelper extends WebTestCase {
return $uriBase;
}
+ /**
+ * The default SimpleBrowser tries to parse all responses, even when
+ * they're not HTML. That fails. We need a better browser.
+ */
+ function &createBrowser() {
+ $browser =& new BetterBrowser();
+ return $browser;
+ }
+
/* Compute the URI for the given action, accounting for us possibly not
* being at the root of the web space.
*/
@@ -84,4 +100,20 @@ class WebTestHelper extends WebTestCase {
}
}
+class BetterBrowser extends SimpleBrowser {
+
+ /**
+ * Overrides _buildPage to only parse responses when the Content Type
+ * looks like HTML.
+ */
+ function &_buildPage($response) {
+ $headers = $response->getHeaders()->getRaw();
+ if (preg_match('#^Content-Type: (text/html|application/xhtml+xml)#m', $headers)) {
+ $page =& parent::_buildPage($response);
+ } else {
+ $page =& new SimplePage($response);
+ }
+ return $page;
+ }
+}
?>
diff --git a/site/app/tests/test_manager.php b/site/app/tests/test_manager.php
index aca4703..01428ef 100644
--- a/site/app/tests/test_manager.php
+++ b/site/app/tests/test_manager.php
@@ -42,18 +42,12 @@
* @subpackage tests.lib
* @since CakePHP Test Suite v 1.0.0.0
*/
+
+DATABASE_CONFIG::useTestConfig();
+
class TestManager {
var $_testExtension = array('.test.php', '.test.thtml', '.test.thtml.php');
- function TestManager() {
- /* @TODO: implement this so the tests consistently use the test db, including web tests
- ConnectionManager::loadDataSource("test");
- $dataSourceTest =& ConnectionManager::getDataSource("test");
- $dataSourceDefault =& ConnectionManager::getDataSource("default");
- $dataSourceDefault = $dataSourceTest;
- */
- }
-
function runAllTests(&$reporter) {
$manager =& new TestManager();