Skip to content

Commit 733ab6b

Browse files
committed
test: Updated Test Cases
1 parent ea0673f commit 733ab6b

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

tests/bootstrap.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
use webfiori\framework\App;
1313
use webfiori\framework\autoload\ClassLoader;
1414
use webfiori\framework\config\JsonDriver;
15+
use webfiori\framework\ThemeManager;
16+
use themes\fioriTheme\NewFTestTheme;
17+
use themes\fioriTheme2\NewTestTheme2;
1518

1619
$DS = DIRECTORY_SEPARATOR;
1720

1821
//the name of tests directory. Update as needed.
1922
define('TESTS_DIRECTORY', 'tests');
20-
define('SQL_SERVER_HOST', 'localhost\SQLEXPRESS');
21-
define('SQL_SERVER_USER', 'sa');
22-
define('SQL_SERVER_PASS', '1234567890@Eu');
23-
define('SQL_SERVER_DB', 'testing_db');
23+
define('SQL_SERVER_HOST', getenv('SQL_SERVER_HOST') ?: 'localhost');
24+
define('SQL_SERVER_USER', getenv('SQL_SERVER_USER') ?: 'sa');
25+
define('SQL_SERVER_PASS', getenv('SA_SQL_SERVER_PASSWORD') ?: '1234567890@Eu');
26+
define('SQL_SERVER_DB', getenv('SQL_SERVER_DB') ?: 'testing_db');
2427
define('ODBC_VERSION', 17);
2528
//an array that contains possible locations at which
2629
//WebFiori Framework might exist.
@@ -112,10 +115,10 @@
112115
$conn = new ConnectionInfo('mssql',SQL_SERVER_USER, SQL_SERVER_PASS, SQL_SERVER_DB, SQL_SERVER_HOST, 1433, [
113116
'TrustServerCertificate' => 'true'
114117
]);
115-
$runner = new SchemaRunner(APP_PATH, '', $conn);
118+
116119
try {
117-
$runner->dropChangesTable();
118-
} catch (\Exception $exc) {
120+
// $runner = new SchemaRunner($conn);
121+
// $runner->dropChangesTable();
119122

120123
} catch (\Throwable $exc) {
121124
fprintf(STDOUT,'Error on register_shutdown_function:'."\n\n");
@@ -125,5 +128,10 @@
125128
});
126129
fprintf(STDOUT, "Registering shutdown function completed.\n");
127130
fprintf(STDOUT,"---------------------------------\n");
131+
fprintf(STDOUT,"Adding themes...\n");
132+
ThemeManager::register(new NewFTestTheme());
133+
ThemeManager::register(new NewTestTheme2());
134+
fprintf(STDOUT,"Done\n");
135+
fprintf(STDOUT,"---------------------------------\n");
128136
fprintf(STDOUT,"Starting to run tests...\n");
129137
fprintf(STDOUT,"---------------------------------\n");

tests/webfiori/framework/test/cli/AddCommandTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testAddDBConnection01() {
8383
'127.0.0.1',
8484
"\n", // Hit Enter to pick default value (port 3306)
8585
'root',
86-
'12345326',
86+
getenv('MYSQL_ROOT_PASSWORD') ?: '12345326',
8787
'testing_db',
8888
"\n", // Hit Enter to pick default value (connection name)
8989
'y'
@@ -108,7 +108,7 @@ public function testAddDBConnection01() {
108108
"Trying to connect to the database...\n",
109109
"Trying with 'localhost'...\n",
110110
"Error: Unable to connect to the database.\n",
111-
"Error: Unable to connect to database: 1045 - Access denied for user 'root'@'localhost' (using password: YES)\n",
111+
"Error: Unable to connect to database: 1045 - Access denied for user 'root'@'127.0.0.1' (using password: YES)\n",
112112
"Would you like to store connection information anyway?(y/N)\n",
113113
"Success: Connection information was stored in application configuration.\n"
114114
], $output);
@@ -129,7 +129,7 @@ public function testAddDBConnection02() {
129129
'127.0.0.1',
130130
"\n", // Hit Enter to pick default value (port 3306)
131131
'root',
132-
'12345326',
132+
getenv('MYSQL_ROOT_PASSWORD') ?: '12345326',
133133
'testing_db',
134134
"\n", // Hit Enter to pick default value (connection name)
135135
'n'
@@ -154,7 +154,7 @@ public function testAddDBConnection02() {
154154
"Trying to connect to the database...\n",
155155
"Trying with 'localhost'...\n",
156156
"Error: Unable to connect to the database.\n",
157-
"Error: Unable to connect to database: 1045 - Access denied for user 'root'@'localhost' (using password: YES)\n",
157+
"Error: Unable to connect to database: 1045 - Access denied for user 'root'@'127.0.0.1' (using password: YES)\n",
158158
"Would you like to store connection information anyway?(y/N)\n",
159159
], $output);
160160
}
@@ -258,7 +258,7 @@ public function testAddSMTPConnection00() {
258258
'127.0.0.1',
259259
"\n", // Hit Enter to pick default value (port 25)
260260
261-
'12345326',
261+
getenv('MYSQL_ROOT_PASSWORD') ?: '12345326',
262262
263263
264264
"\n", // Hit Enter to pick default value (connection name)

tests/webfiori/framework/test/cli/CreateMigrationTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010
class CreateMigrationTest extends CLITestCase {
1111

1212
protected function tearDown(): void {
13-
// Clean up all migration files after each test
13+
// Clean up only specific migration files created by this test
1414
$migrationsDir = APP_PATH . DS . 'database' . DS . 'migrations';
1515
if (is_dir($migrationsDir)) {
16-
$files = glob($migrationsDir . DS . 'Migration*.php');
16+
// Only remove Migration files directly in the migrations directory
17+
$files = glob($migrationsDir . DS . 'Migration[0-9][0-9][0-9].php');
1718
foreach ($files as $file) {
1819
if (is_file($file)) {
1920
unlink($file);
2021
}
2122
}
23+
// Remove Cool* files created by this test
2224
$files = glob($migrationsDir . DS . 'Cool*.php');
2325
foreach ($files as $file) {
2426
if (is_file($file)) {

tests/webfiori/framework/test/writers/DatabaseMigrationWriterTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
class DatabaseMigrationWriterTest extends TestCase {
1414

1515
protected function tearDown(): void {
16-
// Clean up all migration files after each test
16+
// Clean up only the Migration files created by this test (Migration000, Migration001, etc.)
1717
$migrationsDir = APP_PATH . DS . 'database' . DS . 'migrations';
1818
if (is_dir($migrationsDir)) {
19-
$files = glob($migrationsDir . DS . 'Migration*.php');
19+
// Only remove Migration files directly in the migrations directory, not in subdirectories
20+
$files = glob($migrationsDir . DS . 'Migration[0-9][0-9][0-9].php');
2021
foreach ($files as $file) {
2122
if (is_file($file)) {
2223
unlink($file);

0 commit comments

Comments
 (0)