3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
22 * UrlGenerator test case.
24 class UrlGeneratorTest
extends PHPUnit_Framework_TestCase
{
26 private $UrlGenerator;
31 protected function setUp() {
34 $this->gadgetXML
= simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?>
36 <ModulePrefs title="Test" />
39 <h1>Hello, test case!</h1>
44 $this->UrlGenerator
= new UrlGenerator(/* parameters */);
45 $this->context
= new GadgetContext('GADGET');
46 $this->gadget
= new Gadget(false, $this->context
);
47 $this->gadget
->views
= array(DEFAULT_VIEW
=> new ViewSpec('test', $this->gadgetXML
->Content
));
52 * Cleans up the environment after running a test.
54 protected function tearDown() {
56 $this->UrlGenerator
= null;
57 $this->context
= null;
63 public function testGetIframeURL() {
65 $uri = UrlGenerator
::getIframeURL($this->gadget
, $this->context
);
67 $query = parse_url($uri, PHP_URL_QUERY
);
69 $query = explode('&', $query);
73 foreach ($query as $param) {
74 $param = explode('=', $param);
75 list($key, $value) = $param;
76 $args[$key] = $value ?
$value : '';
79 $this->assertArrayHasKey('container', $args);
80 $this->assertArrayHasKey('lang', $args);
81 $this->assertArrayHasKey('country', $args);
82 $this->assertArrayHasKey('view', $args);
83 $this->assertArrayHasKey('url', $args);