public function testReplaceWithDynamicData() { $blueprint = new Blueprint('users', function (Blueprint $table) { $table->column('email')->replaceWith(function (Generator $faker) { return 'some dynamic data'; }); }); $result = $blueprint->build(); $this->assertSame('users', $result->table); $this->assertSame(['id'], $result->primary); $this->assertCount(1, $result->columns); $this->assertSame('email', $result->columns[0]['name']); $this->assertInstanceOf('Closure', $result->columns[0]['replace']); $this->assertSame('some dynamic data', $this->callFakerCallback($result->columns[0]['replace'])); $this->assertNull($result->columns[0]['where']); }
/** * Describe a table with a given callback. * * @param string $name * @param callable $callback * * @return void */ public function table($name, callable $callback) { $blueprint = new Blueprint($name, $callback); $this->blueprints[$name] = $blueprint->build(); }