/[drupal]/contributions/modules/serapi/serapi.test
ViewVC logotype

Contents of /contributions/modules/serapi/serapi.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Sat Aug 15 20:31:38 2009 UTC (3 months, 2 weeks ago) by yaph
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA1, HEAD
Changes since 1.2: +2 -2 lines
File MIME type: text/x-php
Initialize $query_parts variable in serapi_get_search() function before passing it to parse_str()
1 <?php
2 // $Id: serapi.test,v 1.2 2009/07/18 23:19:36 yaph Exp $
3
4 class SerapiTestCase extends DrupalWebTestCase {
5 /**
6 * Implementation of getInfo().
7 */
8 function getInfo() {
9 return array(
10 'name' => t('Search Engine Referer API functionality'),
11 'description' => t('Test whether the sample SERP URLs produce the desired results.'),
12 'group' => t('Search Engine Referer API'),
13 );
14 }
15
16 /**
17 * Test Valid search engine result page URLs
18 */
19 function testValidReferersUrls() {
20 $urls = $this->serapiGetValidTestUrls();
21 foreach ($urls as $url) {
22 $result = serapi_get_search($url);
23 $se_url = $result['url'];
24 $this->assertEqual($url, $se_url, t('Valid URL: @url', array('@url' => $url)));
25 }
26 }
27
28 /**
29 * Test URLs that must return false
30 */
31 function testInvalidReferersUrls() {
32 $urls = $this->serapiGetInvalidTestUrls();
33 foreach ($urls as $url) {
34 $result = serapi_get_search($url);
35 $this->assertFalse($result, t('Invalid URL: @url', array('@url' => $url)));
36 }
37 }
38
39 /**
40 * Returns an array of possible referer URLs for testing purposes
41 *
42 * @return Array
43 * An array of search engine result page URLs
44 */
45 function serapiGetValidTestUrls() {
46 return array(
47 // google
48 'http://www.google.de/search?hl=de&q=drupal&btnG=Google-Suche&meta=',
49 'http://www.google.com/search?q=drupal',
50 'http://www.google.com/search?q=drupal+cms&ie=utf-8&oe=utf-8',
51 // yahoo
52 'http://search.yahoo.com/search?p=drupal&vc=&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8',
53 'http://de.search.yahoo.com/search?p=drupal&fr=yfp-t-501&ei=UTF-8&rd=r1',
54 'http://de.search.yahoo.com/search?p=drupal+cms&ei=UTF-8&fr=moz2',
55 // ask
56 'http://de.ask.com/web?q=drupal&qsrc=0&o=0&l=dir&s=&part=&dm=lang',
57 'http://www.ask.com/web?q=drupal&search=search&qsrc=0&o=312&l=dir',
58 'http://de.ask.com/web?q=is+drupal+a+framework&qsrc=1&o=312&l=dir&s=&part=&dm=all',
59 // live
60 'http://www.bing.com/search?q=drupal&go=&form=QBRE&qs=n',
61 'http://www.bing.com/search?q=drupal+cms&go=&form=QBRE&qs=n',
62 'http://www.bing.com/search?q=live+search+sucks&go=&form=QBRE&qs=n',
63 // aol - better use google in the first place
64 'http://search.aol.com/aol/search?s_it=searchbox.webhome&query=drupal+cms',
65 'http://suche.aol.de/aol/search?q=drupal+cms&langRestrict=2',
66 'http://busqueda.aol.es/aol/search?invocationType=topsearchbox&query=drupal&rp=',
67 // altavista
68 'http://www.altavista.com/web/results?itag=ody&q=drupal&kgs=1&kls=0',
69 'http://de.altavista.com/web/results?itag=ody&q=drupal&kgs=1&kls=0',
70 'http://es.altavista.com/web/results?itag=ody&q=drupal+content+management+framework&kgs=1&kls=0',
71 // alltheweb
72 'http://www.alltheweb.com/search?q=drupal+framework',
73 'http://www.alltheweb.com/search?cat=web&cs=iso88591&q=drupal+cms&rys=0&itag=crv&_sb_lang=pref',
74 'http://www.alltheweb.com/search?cat=web&cs=iso88591&q=drupal&rys=0&itag=crv&_sb_lang=pref'
75 );
76 }
77
78 /**
79 * Returns an array of referer URLs that should not be processed
80 *
81 * @return Array
82 * An array of search engine result page URLs
83 */
84 function serapiGetInvalidTestUrls() {
85 return array(
86 'http://drupal.org/',
87 'http://ramiro.org/',
88 'unkownscheme://foo.bar/',
89 );
90 }
91 }

  ViewVC Help
Powered by ViewVC 1.1.2