Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/tests/views/addons/display.test.php
diff options
context:
space:
mode:
Diffstat (limited to 'site/app/tests/views/addons/display.test.php')
-rw-r--r--site/app/tests/views/addons/display.test.php122
1 files changed, 22 insertions, 100 deletions
diff --git a/site/app/tests/views/addons/display.test.php b/site/app/tests/views/addons/display.test.php
index abaa42f..942a56b 100644
--- a/site/app/tests/views/addons/display.test.php
+++ b/site/app/tests/views/addons/display.test.php
@@ -82,7 +82,7 @@ class AddonTest extends WebTestHelper {
function testRemoraPage() {
//just checks if the page works or not
- $this->assertWantedPattern('/Mozilla Add-ons/i', "pattern detected");
+ $this->assertWantedPattern('/'.SITE_NAME.'/i', "pattern detected");
}
function testDisplay() {
@@ -95,11 +95,27 @@ class AddonTest extends WebTestHelper {
$this->actionPath = $this->actionPath("");
$this->authorPattern = "@<h4 class=\"author\">by +<a href=\"{$this->actionPath}/user/{$userid}\" class=\"profileLink\">{$username}</a> ?</h4>@";
$this->assertWantedPattern($this->authorPattern, htmlentities($this->authorPattern));
-
+ // Icon
+ $wantedPattern = "#<img src=\"" . $this->controller->Image->getAddonIconURL($this->id) . "\" class=\"addon-icon\" alt=\"\" />#";
+ $this->assertWantedPattern($wantedPattern, htmlentities($wantedPattern));
+ // Preview
+ $wantedPattern = '#<img src="' . $this->controller->Image->getHighlightedPreviewURL($this->id) . '" alt="" />#';
+ $this->assertWantedPattern($wantedPattern, htmlentities($wantedPattern));
//@TODO Size: Figure out some way to use the Number Helper in this test
//$this->wantedPattern = "#<span>\(" . $this->data['Version'][0]['File'][0]['size'] . "KB\)</span>#";
//$this->assertWantedPattern($this->wantedPattern, htmlentities($this->wantedPattern));
-
+
+ //check the main version area
+ $this->wantedPattern = "@<h5>" . sprintf(_('addon_display_header_version'), $this->data['Version'][0]['Version']['version']) . " <span title=\"" . strftime(_('datetime'), strtotime($this->data['Version'][0]['Version']['created'])) . "\">&mdash; " . strftime(_('date'), strtotime($this->data['Version'][0]['Version']['created'])) . "</span> &mdash; .*</h5>@";
+ $this->assertWantedPattern($this->wantedPattern, htmlentities($this->wantedPattern));
+ $this->wantedPattern = "#<p {$this->data['Version'][0]['Translation']['releasenotes']['locale_html']}>" . $this->data['Version'][0]['Translation']['releasenotes']['string'] . "</p>#";
+ $this->assertWantedPattern($this->wantedPattern, htmlentities($this->wantedPattern));
+ // check the version at the top title
+ $this->wantedPattern = "#" . $this->data['Version'][0]['Version']['version'] . "#";
+ $this->assertWantedPattern($this->wantedPattern, htmlentities($this->wantedPattern));
+ // check if previous versions link is displayed
+ $this->wantedPattern = _('addons_display_version_history');
+ $this->assertLink($this->wantedPattern, htmlentities($this->wantedPattern));
// tags
foreach ($this->tagData as $tag) {
$this->wantedPattern = "@<li><a href=\"[^\"]+\"( )*>" . $tag['Translation']['name']['string'] . "</a></li>@";
@@ -111,105 +127,11 @@ class AddonTest extends WebTestHelper {
$this->wantedPattern = "@It works but not well.@";
$this->assertWantedPattern($this->wantedPattern, htmlentities($this->wantedPattern));
- }
-
- function testVersion() {
- $this->getAction("/addon/" . $this->id);
- phpQuery::newDocument($this->_browser->getContent());
-
- // Check the version detail area.
- $version_link = pq('h5#version-detail a');
- $version = $this->data['Version'][0]['Version']['version'];
- $this->assertEqual($version_link->text(), sprintf(_('addon_display_header_version'), $version));
- $link = sprintf('addons/versions/%s#version-%s', $this->id, $version);
- $this->assertEqual($version_link->attr('href'), $this->controller->url($link));
-
- $span = pq('h5#version-detail span');
- $created = strtotime($this->data['Version'][0]['Version']['created']);
- $this->assertEqual($span->attr('title'), strftime(_('datetime'), $created));
- $this->assertEquiv($span->text(), '— '.strftime(_('date'), $created));
-
- $notes = $this->data['Version'][0]['Translation']['releasenotes']['string'];
- $this->assertEquiv(pq('#release-notes')->text(), $notes);
-
- // check the version at the top title
- $this->wantedPattern = "#" . $this->data['Version'][0]['Version']['version'] . "#";
- $this->assertWantedPattern($this->wantedPattern, htmlentities($this->wantedPattern));
- // check if previous versions link is displayed
- $link = $this->controller->url('addons/versions/'.$this->id);
- $text = ___('addons_display_see_all_versions');
- $this->assertLinkLocation($link, $text);
+ // If gettext can't find the translation, it just returns what it was given
+ $this->assertNotEqual(_('addons_display_version_history'), 'addons_display_version_history');
}
-
- function testIcon() {
- $this->getAction("/addon/" . $this->id);
- phpQuery::newDocument($this->_browser->getContent());
-
- $img = pq('#addon-summary .name img.addon-icon');
- $this->assertEqual($img->attr('src'), $this->controller->Image->getAddonIconURL($this->id));
- }
-
- function testPreviewsWithMoreImages() {
- // Check the preview images for addon 7. It has 2 in total.
- $this->getAction("/addon/" . $this->id);
- phpQuery::newDocument($this->_browser->getContent());
- $previews = $this->controller->Preview->findAllByAddonId($this->id,
- array('id', 'addon_id', 'caption'),
- 'highlight desc');
-
- // Check the main preview image.
- $this->checkImage($previews[0], '.preview-img a', '.preview-img img');
-
- // Check the More Images section.
- $this->assertEqual(pq('#addon-info h4:first')->text(), ___('addons_display_more_images'));
- $this->checkImage($previews[1], '.addon-images li a', '.addon-images li a img');
-
- //$this->getAction("/addon/" . $this->id);
- }
-
- function testPreviewsWithoutMoreImages() {
- // Addon 9 only has one preview image.
- $id = 9;
- $this->getAction("/addon/" . $id);
- phpQuery::newDocument($this->_browser->getContent());
- $previews = $this->controller->Preview->findAllByAddonId($id,
- array('id', 'addon_id', 'caption'),
- 'highlight desc');
- // Check the main preview image.
- $this->checkImage($previews[0], '.preview-img a', '.preview-img img');
- // No More Images section.
- $this->assertNotEqual(pq('#addon-info h4:first')->text(), ___('addons_display_more_images'));
- $this->assertEqual(pq('#addon-info .addon-images')->size(), 0);
- }
-
- function testPreviewsDefaultImage() {
- // Addon 4022 only has no preview images.
- $id = 4022;
- $this->getAction("/addon/" . $id);
- phpQuery::newDocument($this->_browser->getContent());
- $this->assertEqual(pq('.preview-img img')->attr('src'), $this->controller->base.'/img/no-preview.png');
- // No More Images section.
- $this->assertNotEqual(pq('#addon-info h4:first')->text(), ___('addons_display_more_images'));
- $this->assertEqual(pq('#addon-info .addon-images')->size(), 0);
- }
-
- function checkImage($preview, $link_selector, $image_selector) {
- list($thumb, $full, $caption) = $this->_previewData($preview);
- $link = pq($link_selector);
- $image = pq($image_selector);
- $this->assertEqual($link->attr('href'), $full);
- $this->assertEqual($link->attr('title'), $caption);
- $this->assertEqual($image->attr('src'), $thumb);
- }
-
- function _previewData($preview) {
- $thumb = $this->controller->Image->getPreviewURL($preview['Preview']['id']);
- $full = $this->controller->Image->getPreviewURL($preview['Preview']['id'], 'full');
- $caption = $preview['Translation']['caption']['string'];
- return array($thumb, $full, $caption);
- }
-
+
/**
* bug 412580 was a bug about some UTF-8 characters breaking out HTML sanitization.
* Make sure this does not happen anymore.