Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ReleaseCheckList.test.php « core « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80321507e2ad813686393e13aad14a1330a0c68e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
if(!defined("PIWIK_PATH_TEST_TO_ROOT")) {
	define('PIWIK_PATH_TEST_TO_ROOT', getcwd().'/../..');
}
if(!defined('PIWIK_CONFIG_TEST_INCLUDED'))
{
	require_once PIWIK_PATH_TEST_TO_ROOT . "/tests/config_test.php";
}

//Zend_Loader::loadClass('Piwik_');

class Test_Piwik_ReleaseCheckList extends UnitTestCase
{
	public function test_checkPatchedQuickform()
	{
		// we patched quickform so that it supports SELECT optgroup html tags
		// see patch: http://pear.php.net/bugs/bug.php?id=1283&edit=12&patch=add-optgroup-support&revision=latest
		$this->assertTrue(method_exists('HTML_QuickForm_select', '_optionToHtml'));
		$this->assertTrue(method_exists('HTML_QuickForm_select', '_isInOptGroup'));
	}
	
    public function test_checkThatConfigurationValuesAreProductionValues()
    {
    	$this->globalConfig = parse_ini_file(PIWIK_PATH_TEST_TO_ROOT . '/config/global.ini.php', true);
//    	var_dump($globalConfig);
    	$this->checkEqual(array('Debug' => 'always_archive_data_day'), '0');
    	$this->checkEqual(array('Debug' => 'always_archive_data_period'), '0');
    	$this->checkEqual(array('Debug' => 'enable_sql_profiler'), '0');
    	$this->checkEqual(array('General' => 'time_before_today_archive_considered_outdated'), '10');
    	$this->checkEqual(array('General' => 'enable_browser_archiving_triggering'), '1');
    	$this->checkEqual(array('General' => 'default_language'), 'en');
    	$this->checkEqual(array('Tracker' => 'record_statistics'), '1');
    	$this->checkEqual(array('Tracker' => 'visit_standard_length'), '1800');
    	$this->checkEqual(array('Tracker' => 'enable_detect_unique_visitor_using_settings'), '1');
    	// logging messages are disabled
    	$this->checkEqual(array('log' => 'logger_message'), '');
    	$this->checkEqual(array('log' => 'logger_exception'), array('screen'));
    	$this->checkEqual(array('log' => 'logger_error'), array('screen'));
    	$this->checkEqual(array('log' => 'logger_api_call'), null);
    }
    
    public function test_templatesDontContainDebug()
    {
    	$patternFailIfFound = '{debug}';
    	$files = Piwik::globr(PIWIK_INCLUDE_PATH . '/plugins', '*.tpl');
    	foreach($files as $file)
    	{
    		$content = file_get_contents($file);
    		$this->assertFalse(strpos($content, $patternFailIfFound), 'found in '.$file);
    	}
    }
    
    private function checkEqual($key, $valueExpected)
    {
    	$section = key($key);
    	$optionName = current($key);
    	$value = null;
    	if(isset($this->globalConfig[$section][$optionName]))
    	{
	    	$value = $this->globalConfig[$section][$optionName];
    	}
    	$this->assertEqual($value, $valueExpected, "$section -> $optionName was '$value', expected '$valueExpected'");
    }
    
    public function test_checkThatGivenPluginsAreDisabledByDefault()
    {
    	$pluginsShouldBeDisabled = array(
    		'DBStats',
    		'Goals',
    		'Live',
    	);
    	foreach($pluginsShouldBeDisabled as $pluginName)
    	{
	    	if(in_array($pluginName, $this->globalConfig['Plugins']['Plugins']))
	    	{
	    		throw new Exception("Plugin $pluginName is enabled by default but shouldn't.");
	    	}
    	}
    	
    }
    /**
     * test that the profiler is disabled (mandatory on a production server)
     */
    public function test_profilingDisabledInProduction()
    {
    	require_once 'Tracker/Db.php';
    	$this->assertTrue(Piwik_Tracker_Db::isProfilingEnabled() === false, 'SQL profiler should be disabled in production! See Piwik_Tracker_Db::$profiling');
    }
    

	function test_piwikTrackerDebugIsOff()
	{
		$this->assertTrue(!isset($GLOBALS['PIWIK_TRACKER_DEBUG']));
		include PIWIK_PATH_TEST_TO_ROOT . "/piwik.php";
		$this->assertTrue($GLOBALS['PIWIK_TRACKER_DEBUG'] === false);
	}

	function test_ajaxLibraryVersions()
	{
		Piwik::createConfigObject();
		Zend_Registry::get('config')->setTestEnvironment();	

		$jqueryJs = file_get_contents( PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery.js', false, NULL, 0, 512 );
		$this->assertTrue( preg_match('/jQuery (?:JavaScript Library )?v?([0-9.]+)/', $jqueryJs, $matches) );
		$this->assertEqual( $matches[1], Zend_Registry::get('config')->General->jquery_version );

		$jqueryuiJs = file_get_contents( PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery-ui.js', false, NULL, 0, 512 );
		$this->assertTrue( preg_match('/jQuery UI ([0-9.]+)/', $jqueryuiJs, $matches) );
		$this->assertEqual( $matches[1], Zend_Registry::get('config')->General->jqueryui_version );


		$swfobjectJs = file_get_contents( PIWIK_DOCUMENT_ROOT . '/libs/swfobject/swfobject.js', false, NULL, 0, 512 );
		$this->assertTrue( preg_match('/SWFObject v([0-9.]+)/', $swfobjectJs, $matches) );
		$this->assertEqual( $matches[1], Zend_Registry::get('config')->General->swfobject_version );
	}
}