'alveolata', 'sections' => [ [ 'name' => 'storage', 'sections' => [ [ 'name' => 'sqltable', 'setup' => function (&$environment) { $environment['path_database'] = '/tmp/localdb.sqlite'; exec(sprintf('echo "" > %s', $environment['path_database'])); $database = \alveolata\database\make( 'sqlite', [ 'path' => $environment['path_database'], ] ); $tablename = '_testtable_'; $fields = [ [ 'name' => 'name', 'type' => 'VARCHAR(64)', 'null_allowed' => false, 'default' => '', ], ]; $environment['storage'] = \alveolata\storage\implementation_sqltable::make( $database, $tablename, $fields ); $environment['storage']->setup(); }, 'sections' => [ [ 'name' => 'create_delete', 'cases' => [ [ 'name' => 'test', 'procedure' => function ($assert, $environment) { // constants $value = [ 'name' => 'foox', ]; // execution & assertions $assert->runs( function () use (&$environment, &$value) { $key = $environment['storage']->create($value); $environment['storage']->delete($key); } ); } ], ] ], [ 'name' => 'read', 'cases' => [ [ 'name' => 'test', 'procedure' => function ($assert, $environment) { // constants $value = [ 'name' => 'foox', ]; // setup $key = $environment['storage']->create($value); // execution $value_read = $environment['storage']->read($key); // assertions $assert->equal($value_read, $value); // cleanup $environment['storage']->delete($key); } ], ] ], [ 'name' => 'search', 'cases' => [ [ 'name' => 'test', 'procedure' => function ($assert, $environment) { // constants $value = [ 'name' => 'foox', ]; // setup $key = $environment['storage']->create($value); // execution $keys = $environment['storage']->search($value); // assertions $assert->equal($keys, [$key]); // cleanup $environment['storage']->delete($key); } ], ] ], [ 'name' => 'update', 'cases' => [ [ 'name' => 'test', 'procedure' => function ($assert, $environment) { // constants $value1 = [ 'name' => 'foox', ]; $value2 = [ 'name' => 'barx', ]; // setup $key = $environment['storage']->create($value1); // execution $environment['storage']->update($key, $value2); $value_read = $environment['storage']->read($key); // assertions $assert->equal($value_read, $value2); // cleanup $environment['storage']->delete($key); } ], ] ], ], 'cleanup' => function (&$environment) { $environment['storage']->teardown(); exec(sprintf('rm -f %s', $environment['path_database'])); } ] ] ], ] ] );