From 1136d71adcfdc5e4f0d0834e5e53342ba516c2cd Mon Sep 17 00:00:00 2001 From: Brandon Shipley Date: Fri, 20 Mar 2026 20:57:00 -0700 Subject: [PATCH] tests/schema --- tests/schema.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/schema.php diff --git a/tests/schema.php b/tests/schema.php new file mode 100644 index 0000000..8d92656 --- /dev/null +++ b/tests/schema.php @@ -0,0 +1,44 @@ + $iterator + */ +$iterator = new DirectoryIterator(__DIR__ . DS . 'Fixture'); +foreach ($iterator as $file) { + if (!preg_match('/(\w+)Fixture.php$/', (string)$file, $matches)) { + continue; + } + + $name = $matches[1]; + $tableName = Inflector::underscore($name); + $class = 'CakeAddresses\\Test\\Fixture\\' . $name . 'Fixture'; + try { + $object = (new ReflectionClass($class))->getProperty('fields'); + } catch (ReflectionException $e) { + continue; + } + + $array = $object->getDefaultValue(); + $constraints = $array['_constraints'] ?? []; + $indexes = $array['_indexes'] ?? []; + unset($array['_constraints'], $array['_indexes'], $array['_options']); + $table = [ + 'table' => $tableName, + 'columns' => $array, + 'constraints' => $constraints, + 'indexes' => $indexes, + ]; + $tables[$tableName] = $table; +} + +return $tables;