Skip to content

Commit c59fac0

Browse files
committed
test: Added Check for Files
1 parent 2fcb0c5 commit c59fac0

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

tests/WebFiori/Framework/Tests/Cli/DBClassWritterTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public function test00() {
3737
$mapper->setNamespace('WebFiori\\Entity');
3838
$writter = new DBClassWriter('UserDBClass', 'WebFiori\\Db', $table);
3939
$writter->writeClass();
40+
41+
// Check if file was written and require it
42+
$filePath = $writter->getPath() . DS . $writter->getName() . '.php';
43+
$this->assertTrue(file_exists($filePath), "Class file was not created: $filePath");
44+
require_once $filePath;
4045
$this->assertTrue(class_exists($writter->getName(true)));
4146
$this->removeClass($writter->getName(true));
4247
}
@@ -51,6 +56,11 @@ public function test01() {
5156
$mapper->setNamespace('WebFiori\\Entity');
5257
$writter = new DBClassWriter('EmployeeDB', 'WebFiori\\Db', $table);
5358
$writter->writeClass();
59+
60+
// Check if file was written and require it
61+
$filePath = $writter->getPath() . DS . $writter->getName() . '.php';
62+
$this->assertTrue(file_exists($filePath), "Class file was not created: $filePath");
63+
require_once $filePath;
5464
$this->assertTrue(class_exists($writter->getName(true)));
5565
$this->removeClass($writter->getName(true));
5666
}
@@ -65,6 +75,11 @@ public function test02() {
6575
$mapper->setNamespace('WebFiori\\Entity');
6676
$writter = new DBClassWriter('PositionDB', 'WebFiori\\Db', $table);
6777
$writter->writeClass();
78+
79+
// Check if file was written and require it
80+
$filePath = $writter->getPath() . DS . $writter->getName() . '.php';
81+
$this->assertTrue(file_exists($filePath), "Class file was not created: $filePath");
82+
require_once $filePath;
6883
$this->assertTrue(class_exists($writter->getName(true)));
6984
$this->removeClass($writter->getName(true));
7085
}
@@ -81,6 +96,11 @@ public function test03() {
8196
$this->assertEquals('ok-connection', $writter->getConnectionName());
8297
$writter->includeColumnsUpdate();
8398
$writter->writeClass();
99+
100+
// Check if file was written and require it
101+
$filePath = $writter->getPath() . DS . $writter->getName() . '.php';
102+
$this->assertTrue(file_exists($filePath), "Class file was not created: $filePath");
103+
require_once $filePath;
84104
$this->assertTrue(class_exists($writter->getName(true)));
85105
$this->removeClass($writter->getName(true));
86106
}

tests/WebFiori/Framework/Tests/Writers/DatabaseMigrationWriterTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function test00() {
5555
], $writter->getUseStatements());
5656
$writter->writeClass();
5757

58+
// Check if file was written and require it
59+
$filePath = $writter->getPath() . DS . $writter->getName() . '.php';
60+
$this->assertTrue(file_exists($filePath), "Class file was not created: $filePath");
61+
require_once $filePath;
5862
$this->assertTrue(class_exists($clazz));
5963
$runner->register($clazz);
6064
$allClasses[] = $clazz;

0 commit comments

Comments
 (0)