SHINDIG-917
[shindig.git] / php / test / common / UrlGeneratorTest.php
blob06aac426f62558fec5557ea404ae5b889a8b6912
1 <?php
2 /**
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
18 * under the License.
21 /**
22 * UrlGenerator test case.
24 class UrlGeneratorTest extends PHPUnit_Framework_TestCase {
26 private $UrlGenerator;
27 private $context;
28 private $gadget;
29 private $gadgetXML;
31 protected function setUp() {
32 parent::setUp();
34 $this->gadgetXML = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?>
35 <Module>
36 <ModulePrefs title="Test" />
37 <Content type="html">
38 <![CDATA[
39 <h1>Hello, test case!</h1>
40 ]]>
41 </Content>
42 </Module>');
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));
51 /**
52 * Cleans up the environment after running a test.
54 protected function tearDown() {
56 $this->UrlGenerator = null;
57 $this->context = null;
58 $this->gadget = null;
60 parent::tearDown();
63 public function testGetIframeURL() {
65 $uri = UrlGenerator::getIframeURL($this->gadget, $this->context);
67 $query = parse_url($uri, PHP_URL_QUERY);
69 $query = explode('&', $query);
71 $args = array();
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);