diff --git a/tests/Unit/ActiveQueryTest.php b/tests/Unit/ActiveQueryTest.php new file mode 100644 index 0000000..1bbbcfa --- /dev/null +++ b/tests/Unit/ActiveQueryTest.php @@ -0,0 +1,48 @@ + [ + SchemaInterface::ENTITY => \stdClass::class, + SchemaInterface::DATABASE => 'default', + SchemaInterface::TABLE => 'notes', + SchemaInterface::PRIMARY_KEY => 'id', + SchemaInterface::COLUMNS => ['id', 'text'], + SchemaInterface::SCHEMA => [], + SchemaInterface::RELATIONS => [], + ], + ]); + Facade::setContainer(ConfigurableContainer::returning(ORMInterface::class, $orm)); + + $query = new ActiveQuery('note'); + + Assert::same($query->getRole(), 'note'); + Assert::string($query->sqlStatement())->contains('FROM "notes"'); + } +} diff --git a/tests/Unit/BridgeTest.php b/tests/Unit/BridgeTest.php new file mode 100644 index 0000000..a782322 --- /dev/null +++ b/tests/Unit/BridgeTest.php @@ -0,0 +1,49 @@ +register(); + + Assert::same(Facade::getOrm(), $orm); + } + + public function yiiBootstrapBindsTheContainerIntoTheFacade(): void + { + $orm = Memory::orm(); + $bootstrap = require \dirname(__DIR__, 2) . '/src/Bridge/Yii3/yii-bootstrap.php'; + + $bootstrap['cycle-active-record'](ConfigurableContainer::returning(ORMInterface::class, $orm)); + + Assert::same(Facade::getOrm(), $orm); + } +} diff --git a/tests/Unit/DeprecatedAliasTest.php b/tests/Unit/DeprecatedAliasTest.php new file mode 100644 index 0000000..49231c4 --- /dev/null +++ b/tests/Unit/DeprecatedAliasTest.php @@ -0,0 +1,29 @@ +getName(), TransactionException::class); + } +}