public function testCreateUsingSequence() { Fabricate::config(function ($config) { $config->sequence_start = 100; }); $results = Fabricate::attributes_for('Post', 10, function ($data, $world) { return ['id' => $world->sequence('id'), 'title' => $world->sequence('title', 1, function ($i) { return "Title {$i}"; })]; }); $this->assertEquals(100, $results[0]['id']); $this->assertEquals('Title 1', $results[0]['title']); $this->assertEquals(109, $results[9]['id']); $this->assertEquals('Title 10', $results[9]['title']); }
} while ($root !== $lastRoot); throw new Exception('Cannot find the root of the application, unable to run tests'); }; $root = $findRoot(__FILE__); unset($findRoot); chdir($root); require_once 'vendor/cakephp/cakephp/src/basics.php'; require_once 'vendor/autoload.php'; require_once 'config/bootstrap.php'; define('ROOT', $root . DS . 'tests' . DS . 'test_app' . DS); define('APP', ROOT . 'App' . DS); define('CONFIG', $root . DS . 'config' . DS); define('TMP', sys_get_temp_dir() . DS); Configure::write('debug', true); Configure::write('App', ['namespace' => 'App', 'paths' => ['plugins' => [ROOT . 'Plugin' . DS], 'templates' => [ROOT . 'App' . DS . 'Template' . DS]]]); Cake\Cache\Cache::config(['_cake_core_' => ['engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true, 'path' => '/tmp'], '_cake_model_' => ['engine' => 'File', 'prefix' => 'cake_model_', 'serialize' => true, 'path' => '/tmp']]); if (!getenv('db_dsn')) { putenv('db_dsn=sqlite:///:memory:?quoteIdentifiers=1'); } if (!getenv('DB')) { putenv('DB=sqlite'); } ConnectionManager::config('test', ['url' => getenv('db_dsn')]); Plugin::load('DelayedJobs', ['path' => dirname(dirname(__FILE__)) . DS]); Plugin::load('Crud', ['path' => dirname(dirname(__FILE__)) . DS . 'vendor' . DS . 'friendsofcake' . DS . 'crud' . DS]); DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); Fabricate::config(function ($config) { $config->adaptor = new CakeFabricateAdaptor(); });