Skip to content

Commit 3088691

Browse files
committed
fix: corrected config files and folders for tests
1 parent 2710a90 commit 3088691

File tree

8 files changed

+28
-27
lines changed

8 files changed

+28
-27
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ coverage.txt
6060
tests/logs
6161
tests/test.db
6262
tests/test.db-journal
63-
tests/config/database.php
64-
tests/config/ldap.php
63+
tests/content/core/config/database.php
64+
tests/content/core/config/ldap.php
65+
tests/content/upgrades
6566
tests/fixtures/path-to-delete/foo.bar.baz
6667

6768
# Jest related stuff

phpmyfaq/src/phpMyFAQ/Instance/Setup.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function checkDirs(array $dirs): array
7575

7676
foreach ($dirs as $dir) {
7777
if (false === is_dir($this->rootDir . $dir)) {
78-
// If the folder does not exist try to create it
78+
// If the folder does not exist, try to create it
7979
if (false === mkdir($this->rootDir . $dir)) {
8080
// If the folder creation fails
8181
$failedDirs[] = 'Folder [' . $dir . '] could not be created.';
@@ -105,12 +105,12 @@ public function checkDirs(array $dirs): array
105105
}
106106

107107
/**
108-
* Creates the file /config/database.php.
108+
* Creates the file /content/core/config/database.php.
109109
*
110110
* @param int[]|string[] $data Array with database credentials
111111
* @param string $folder Folder
112112
*/
113-
public function createDatabaseFile(array $data, string $folder = '/config'): int|bool
113+
public function createDatabaseFile(array $data, string $folder = '/content/core/config'): int|bool
114114
{
115115
return file_put_contents(
116116
$this->rootDir . $folder . '/database.php',
@@ -127,12 +127,12 @@ public function createDatabaseFile(array $data, string $folder = '/config'): int
127127
}
128128

129129
/**
130-
* Creates the file /config/ldap.php.
130+
* Creates the file /content/core/config/ldap.php.
131131
*
132132
* @param int[]|string[] $data Array with LDAP credentials
133133
* @param string $folder Folder
134134
*/
135-
public function createLdapFile(array $data, string $folder = '/config'): int|bool
135+
public function createLdapFile(array $data, string $folder = '/content/core/config'): int|bool
136136
{
137137
return file_put_contents(
138138
$this->rootDir . $folder . '/config/ldap.php',
@@ -147,12 +147,12 @@ public function createLdapFile(array $data, string $folder = '/config'): int|boo
147147
}
148148

149149
/**
150-
* Creates the file /config/elasticsearch.php
150+
* Creates the file /content/core/config/elasticsearch.php
151151
*
152152
* @param int[]|string[] $data Array with Elasticsearch credentials
153153
* @param string $folder Folder
154154
*/
155-
public function createElasticsearchFile(array $data, string $folder = '/config'): int|bool
155+
public function createElasticsearchFile(array $data, string $folder = '/content/core/config'): int|bool
156156
{
157157
return file_put_contents(
158158
$this->rootDir . $folder . '/config/elasticsearch.php',

phpmyfaq/src/phpMyFAQ/Setup/Installer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ public function startInstall(array $setup = null): void
965965
}
966966

967967
// connect to the database using config/database.php
968-
$dbConfig = new DatabaseConfiguration($rootDir . '/config/database.php');
968+
$dbConfig = new DatabaseConfiguration($rootDir . '/content/core/config/database.php');
969969
try {
970970
$db = Database::factory($dbSetup['dbType']);
971971
} catch (Exception $exception) {

tests/bootstrap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
// The root directory
3030
//
3131
define('PMF_ROOT_DIR', dirname(__DIR__) . '/phpmyfaq');
32-
define('PMF_CONFIG_DIR', dirname(__DIR__) . '/phpmyfaq/content/core/config');
33-
define('PMF_CONTENT_DIR', dirname(__DIR__) . '/phpmyfaq/content');
32+
define('PMF_CONFIG_DIR', dirname(__DIR__) . '/tests/content/core/config');
33+
define('PMF_CONTENT_DIR', dirname(__DIR__) . '/tests/content');
3434

3535
const PMF_LOG_DIR = __DIR__ . '/logs';
3636
const PMF_TEST_DIR = __DIR__;
@@ -39,7 +39,7 @@
3939

4040
$_SERVER['HTTP_HOST'] = 'https://localhost/';
4141

42-
require PMF_CONFIG_DIR . '/constants.php';
42+
require PMF_ROOT_DIR . '/content/core/config/constants.php';
4343

4444
//
4545
// The include directory
@@ -87,4 +87,4 @@
8787
echo $e->getMessage();
8888
}
8989

90-
require PMF_TEST_DIR . '/config/database.php';
90+
require PMF_TEST_DIR . '/content/core/config/database.php';
File renamed without changes.

tests/content/upgrades/.gitkeep

Whitespace-only changes.

tests/phpMyFAQ/Configuration/DatabaseConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class DatabaseConfigurationTest extends TestCase
88
{
99
public function testDBConfigProperties(): void
1010
{
11-
$config = new DatabaseConfiguration(dirname(__FILE__, 3) . '/config/database.php');
11+
$config = new DatabaseConfiguration(dirname(__FILE__, 3) . '/content/core/config/database.php');
1212

1313
$this->assertEquals(dirname(__FILE__, 3) . '/test.db', $config->getServer());
1414
$this->assertEquals(null, $config->getPort());

tests/phpMyFAQ/ConfigurationTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ protected function tearDown(): void
3939
parent::tearDown();
4040
}
4141

42-
public function testSetLdapConfigWithSingleServer()
42+
public function testSetLdapConfigWithSingleServer(): void
4343
{
44-
// Demo data from config/ldap.php
44+
// Demo data from /content/core/config/ldap.php
4545
file_put_contents(
46-
PMF_TEST_DIR . '/config/ldap.php',
46+
PMF_TEST_DIR . '/content/core/config/ldap.php',
4747
"<?php\n" .
4848
"\$PMF_LDAP['ldap_server'] = 'localhost';\n" .
4949
"\$PMF_LDAP['ldap_port'] = '389';\n" .
@@ -65,18 +65,18 @@ public function testSetLdapConfigWithSingleServer()
6565
]
6666
];
6767

68-
$ldapConfig = new LdapConfiguration(PMF_TEST_DIR . '/config/ldap.php');
68+
$ldapConfig = new LdapConfiguration(PMF_TEST_DIR . '/content/core/config/ldap.php');
6969

7070
$this->Configuration->setLdapConfig($ldapConfig);
7171

7272
$this->assertEquals($expected, $this->Configuration->getLdapServer());
7373
}
7474

75-
public function testSetLdapConfigWithMultipleServers()
75+
public function testSetLdapConfigWithMultipleServers(): void
7676
{
77-
// Demo data from config/ldap.php
77+
// Demo data from /content/core/config/ldap.php
7878
file_put_contents(
79-
PMF_TEST_DIR . '/config/ldap.php',
79+
PMF_TEST_DIR . '/content/core/config/ldap.php',
8080
"<?php\n" .
8181
"\$PMF_LDAP['ldap_server'] = 'localhost';\n" .
8282
"\$PMF_LDAP['ldap_port'] = '389';\n" .
@@ -110,17 +110,17 @@ public function testSetLdapConfigWithMultipleServers()
110110
]
111111
];
112112

113-
$ldapConfig = new LdapConfiguration(PMF_TEST_DIR . '/config/ldap.php');
113+
$ldapConfig = new LdapConfiguration(PMF_TEST_DIR . '/content/core/config/ldap.php');
114114
$this->Configuration->setLdapConfig($ldapConfig);
115115

116116
$this->assertEquals($expected, $this->Configuration->getLdapServer());
117117
}
118118

119-
public function testSetLdapConfigWithMultipleServersButDisabled()
119+
public function testSetLdapConfigWithMultipleServersButDisabled(): void
120120
{
121-
// Demo data from config/ldap.php
121+
// Demo data from /content/core/config/ldap.php
122122
file_put_contents(
123-
PMF_TEST_DIR . '/config/ldap.php',
123+
PMF_TEST_DIR . '/content/core/config/ldap.php',
124124
"<?php\n" .
125125
"\$PMF_LDAP['ldap_server'] = 'localhost';\n" .
126126
"\$PMF_LDAP['ldap_port'] = '389';\n" .
@@ -147,7 +147,7 @@ public function testSetLdapConfigWithMultipleServersButDisabled()
147147
]
148148
];
149149

150-
$ldapConfig = new LdapConfiguration(PMF_TEST_DIR . '/config/ldap.php');
150+
$ldapConfig = new LdapConfiguration(PMF_TEST_DIR . '/content/core/config/ldap.php');
151151
$this->Configuration->setLdapConfig($ldapConfig);
152152

153153
$this->assertEquals($expected, $this->Configuration->getLdapServer());

0 commit comments

Comments
 (0)