1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8require_once(__DIR__ . '/tikiimporter_testcase.php'); 9require_once(__DIR__ . '/../../importer/tikiimporter.php'); 10/** 11 * @group importer 12 */ 13class TikiImporter_Test extends TikiImporter_TestCase 14{ 15 public function testGetOptions() 16 { 17 $expectedResult = [['name' => 'name'], 18 ['name' => 'otherName'], 19 ['secondName' => 'something']]; 20 $object = new TikiImporterGranSon(); 21 $this->assertEquals($expectedResult, $object->getOptions()); 22 23 $expectedResult = [['name' => 'someName', 'property1' => 'someProperty'], 24 ['name' => 'differentName', 'property' => 'anotherProperty']]; 25 $object = new TikiImporterFirstChild(); 26 $this->assertEquals($expectedResult, $object->getOptions()); 27 } 28 29 public function testChangePhpSettings() 30 { 31 TikiImporter::changePhpSettings(); 32 $this->assertEquals(E_ALL & ~E_DEPRECATED, ini_get('error_reporting'), 'Should change the value of the error reporting'); 33 $this->assertEquals('on', ini_get('display_errors'), 'Should change the value of display_errors'); 34 $this->assertEquals(0, ini_get('max_execution_time'), 'Should change the value of max_execution_time'); 35 } 36 37 public function testDisplayPhpUploadError() 38 { 39 $this->assertNull(TikiImporter::displayPhpUploadError(-1), 'Should return null if invalid code passed as param'); 40 $this->assertEquals('No file was uploaded.', TikiImporter::displayPhpUploadError(4)); 41 } 42} 43 44 45// dummy classes to test the TikiImporter::getOptions() 46 47class TikiImporterFirstChild extends TikiImporter 48{ 49 public static function importOptions() 50 { 51 return [ 52 ['name' => 'someName', 'property1' => 'someProperty'], 53 ['name' => 'differentName', 'property' => 'anotherProperty'] 54 ]; 55 } 56} 57 58class TikiImporterSecondChild extends TikiImporter 59{ 60 public static function importOptions() 61 { 62 return [ 63 ['name' => 'otherName'], 64 ['secondName' => 'something'] 65 ]; 66 } 67} 68 69class TikiImporterGranSon extends TikiImporterSecondChild 70{ 71 public static function importOptions() 72 { 73 return [ 74 ['name' => 'name'] 75 ]; 76 } 77} 78