Passed
Pull Request — release-2.1 (#6097)
by Mathias
10:40
created

InstallTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testWrite() 0 4 1
A testForumSettings() 0 7 1
A testDatabasePopulation() 0 4 1
A testDBSettings() 0 15 1
A testAdminAccount() 0 11 1
1
<?php
2
3
/**
4
 * The main purpose of this file is to show a list of all errors that were
5
 * logged on the forum, and allow filtering and deleting them.
6
 *
7
 * Simple Machines Forum (SMF)
8
 *
9
 * @package SMF
10
 * @author Simple Machines https://www.simplemachines.org
11
 * @copyright 2020 Simple Machines and individual contributors
12
 * @license https://www.simplemachines.org/about/smf/license.php BSD
13
 *
14
 * @version 2.1 RC2
15
 */
16
17
define('SMFPHPUNIT',TRUE);
18
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
require_once('./install.php');
20
21
final class InstallTest extends TestCase
22
{
23
    public function testWrite() {
24
        load_lang_file();
25
        $var = CheckFilesWritable();
26
        $this->assertEquals(true,$var);
27
    }
28
29
    public function testDBSettings() {
30
        $_POST['db_type'] = 'postgresql';
31
        $_POST['db_prefix'] = 'smf_';
32
        $_POST['db_name'] = 'postgres';
33
        $_POST['db_user'] = 'postgres';
34
        $_POST['db_passwd'] = '';
35
        $_POST['db_server'] = 'localhost';
36
        $_POST['db_port'] = '5432';
37
38
        // updateSettingsFile got different way to detect setting dir...
39
        $GLOBALS['boarddir'] = getcwd();
40
41
        load_lang_file();
42
        $var = DatabaseSettings();
43
        $this->assertEquals(true,$var);
44
    }
45
46
    public function testForumSettings() {
47
        $_SERVER['SERVER_NAME'] = 'localhost';
48
        $_POST['boardurl'] = 'http://localhost';
49
        $_POST['mbname'] = 'My PHPUnit Community';
50
        load_lang_file();
51
        $var = ForumSettings();
52
        $this->assertEquals(true,$var);
53
    }
54
55
    public function testDatabasePopulation() {
56
        load_lang_file();
57
        $var = DatabasePopulation();
58
        $this->assertEquals(true,$var);
59
    }
60
61
    public function testAdminAccount() {
62
        $_POST['username'] = 'Admin';
63
        $_POST['email'] = '[email protected]';
64
        $_POST['password1'] = 'admin';    
65
        $_POST['contbutt'] = '1234';
66
67
        $_POST['password2'] = $_POST['password1'];
68
        $_POST['server_email'] = $_POST['email'];
69
        load_lang_file();
70
        $var = AdminAccount();
71
        $this->assertEquals(true,$var);
72
    }
73
}
74
75
?>