blob: 9da00f02f3d259a3ec034c36b2d5cd0c3c44cc44 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2010 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wayne Beaton (Eclipse Foundation)- initial API and implementation
*******************************************************************************/
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/debug.php");
trace_file_info(__FILE__);
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
require_once '../classes/common.php';
require_once '../classes/TestRunner.class.php';
class CommonTests extends TestCase {
function test_is_valid_project_name() {
$this->assertTrue(isValidProjectId("eclipse"));
$this->assertTrue(isValidProjectId("eclipse.technology"));
$this->assertTrue(isValidProjectId("eclipse.technology.foo"));
$this->assertTrue(isValidProjectId("eclipse.technology.g-foo"));
$this->assertFalse(isValidProjectId(""));
$this->assertFalse(isValidProjectId("eclipse.technology.foo.stuff"));
}
function test_get_parent_project_id() {
$this->assertEquals("eclipse.jdt", getParentProjectId('eclipse.jdt.debugging'));
$this->assertEquals("eclipse", getParentProjectId('eclipse.jdt'));
$this->assertNull(getParentProjectId('eclipse'));
}
function test_is_valid_subproject_id() {
$this->assertTrue(is_valid_subproject_id('eclipse.jdt', 'eclipse.jdt.debugging'));
$this->assertTrue(is_valid_subproject_id('eclipse', 'eclipse.jdt.debugging'));
$this->assertTrue(is_valid_subproject_id('eclipse', 'eclipse.jdt'));
$this->assertFalse(is_valid_subproject_id('eclipse', 'technology.jdt'));
}
function testUrlFileNormalization() {
$this->assertEquals("/test/foo1.php", normalizeRelativeUrl("http://www.eclipse.org/test/foo1.php"));
$this->assertEquals("/test/foo2.php", normalizeRelativeUrl("/test/foo2.php"));
$this->assertEquals("/test/foo3.php", normalizeRelativeUrl("test/foo3.php"));
$this->assertEquals("/test-2/foo3.php", normalizeRelativeUrl("test-2/foo3.php"));
$this->assertEquals("/foo/project-info/project-page-paragraph.html", normalizeRelativeUrl("/foo/project-info/project-page-paragraph.html"));
$this->assertEquals("/modeling/gmp/gmf-notation/project-info/project-page-paragraph.html", normalizeRelativeUrl("http://localhost/modeling/gmp/gmf-notation/project-info/project-page-paragraph.html"));
$this->assertNull(normalizeRelativeUrl("http://wiki.eclipse.org/junk"));
}
function testUrlHttpNormalization() {
$this->assertEquals("http://www.eclipse.org/test/foo1.php", normalizeHttpUrl("http://www.eclipse.org/test/foo1.php"));
$this->assertEquals("http://eclipse.org/test/foo2.php", normalizeHttpUrl("http://eclipse.org/test/foo2.php"));
$this->assertEquals("http://eclipse.org/test/foo3.php", normalizeHttpUrl("/test/foo3.php"));
$this->assertEquals("http://eclipse.org/test/foo4.php", normalizeHttpUrl("test/foo4.php"));
$this->assertEquals("http://git.eclipse.org/c/jetty/org.eclipse.jetty.admin.git/plain/jetty-project-plan.xml", normalizeHttpUrl("http://git.eclipse.org/c/jetty/org.eclipse.jetty.admin.git/plain/jetty-project-plan.xml"));
$this->assertNull(normalizeHttpUrl("http://junk/test/foo4.php"));
$this->assertEquals("http://wiki.eclipse.org/junk", normalizeHttpUrl("http://wiki.eclipse.org/junk"));
$this->assertEquals("http://wiki.eclipse.org/DSDP/Restructuring_Review", normalizeHttpUrl("http://wiki.eclipse.org/DSDP/Restructuring_Review"));
// Test some wiki links;
$this->assertEquals("http://wiki.eclipse.org/test/foo1.php", normalizeHttpUrl("http://wiki.eclipse.org/test/foo1.php", array('wiki')));
}
}
$App = new App();
$runner = new TestRunner("CommonTests");
$runner->run_tests();
?>