Skip to content

Commit 472b0b1

Browse files
committed
added a test when trying to load the schema without a cache or lock file
1 parent 446d152 commit 472b0b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/TDBMDaoGeneratorTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,20 @@ protected function setUp(): void
104104
//$this->tdbmDaoGenerator->setComposerFile($this->rootPath.'composer.json');
105105
}
106106

107+
public function testGetSchemaCrashWithoutLock()
108+
{
109+
//let's delete the lock file
110+
$schemaFilePath = TDBMSchemaAnalyzer::getLockFilePath();
111+
if (file_exists($schemaFilePath)) {
112+
unlink($schemaFilePath);
113+
}
114+
//let's check we cannot call get schema without a lock file
115+
$schemaAnalyzer = new SchemaAnalyzer(self::getConnection()->getSchemaManager(), new ArrayCache(), 'prefix_');
116+
$tdbmSchemaAnalyzer = new TDBMSchemaAnalyzer(self::getConnection(), new ArrayCache(), $schemaAnalyzer);
117+
$this->expectException('TheCodingMachine\TDBM\TDBMException');
118+
$schema1 = $tdbmSchemaAnalyzer->getSchema(true);
119+
}
120+
107121
public function testDaoGeneration(): void
108122
{
109123
// Remove all previously generated files.

0 commit comments

Comments
 (0)