Skip to content

Commit d483193

Browse files
committed
Fixed definitions in tests
1 parent bf2e833 commit d483193

File tree

2 files changed

+303
-258
lines changed

2 files changed

+303
-258
lines changed

tests/_support/Traits/Table_Fixtures.php

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,20 @@ public function get_modified_simple_table() {
6161
protected static $schema_slug = 'bork-simple';
6262

6363
public static function get_schema_history(): array {
64-
$columns = new Column_Collection();
64+
$table_name = static::table_name( true );
65+
$callable = function() use ( $table_name ) {
66+
$columns = new Column_Collection();
6567

66-
$columns[] = ( new ID( 'id' ) )->set_length( 11 )->set_type( Column::COLUMN_TYPE_INT );
67-
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
68-
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 )->set_is_index( true );
69-
$columns[] = ( new String_Column( 'something' ) )->set_length( 25 )->set_is_index( true );
68+
$columns[] = ( new ID( 'id' ) )->set_length( 11 )->set_type( Column::COLUMN_TYPE_INT );
69+
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
70+
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 )->set_is_index( true );
71+
$columns[] = ( new String_Column( 'something' ) )->set_length( 25 )->set_is_index( true );
72+
73+
return new Table_Schema( $table_name, $columns );
74+
};
7075

7176
return [
72-
static::SCHEMA_VERSION => new Table_Schema( static::table_name( true ), $columns ),
77+
static::SCHEMA_VERSION => $callable,
7378
];
7479
}
7580

@@ -93,14 +98,18 @@ public function get_simple_table() {
9398
protected static $schema_slug = 'bork-simple';
9499

95100
public static function get_schema_history(): array {
96-
$columns = new Column_Collection();
101+
$table_name = static::table_name( true );
102+
$callable = function() use ( $table_name ) {
103+
$columns = new Column_Collection();
97104

98-
$columns[] = ( new ID( 'id' ) )->set_length( 11 )->set_type( Column::COLUMN_TYPE_INT );
99-
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
100-
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 )->set_is_index( true );
105+
$columns[] = ( new ID( 'id' ) )->set_length( 11 )->set_type( Column::COLUMN_TYPE_INT );
106+
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
107+
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 )->set_is_index( true );
108+
return new Table_Schema( $table_name, $columns );
109+
};
101110

102111
return [
103-
static::SCHEMA_VERSION => new Table_Schema( static::table_name( true ), $columns ),
112+
static::SCHEMA_VERSION => $callable,
104113
];
105114
}
106115

@@ -124,14 +133,18 @@ public function get_simple_table_alt_group(): Table {
124133
protected static $schema_slug = 'bork-simple-alt';
125134

126135
public static function get_schema_history(): array {
127-
$columns = new Column_Collection();
136+
$table_name = static::table_name( true );
137+
$callable = function() use ( $table_name ) {
138+
$columns = new Column_Collection();
128139

129-
$columns[] = ( new ID( 'id' ) )->set_length( 11 )->set_type( Column::COLUMN_TYPE_INT );
130-
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
131-
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 )->set_is_index( true );
140+
$columns[] = ( new ID( 'id' ) )->set_length( 11 )->set_type( Column::COLUMN_TYPE_INT );
141+
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
142+
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 )->set_is_index( true );
143+
return new Table_Schema( $table_name, $columns );
144+
};
132145

133146
return [
134-
static::SCHEMA_VERSION => new Table_Schema( static::table_name( true ), $columns ),
147+
static::SCHEMA_VERSION => $callable,
135148
];
136149
}
137150

@@ -153,14 +166,18 @@ public function get_indexless_table() {
153166
protected static $schema_slug = 'bork-noindex';
154167

155168
public static function get_schema_history(): array {
156-
$columns = new Column_Collection();
169+
$table_name = static::table_name( true );
170+
$callable = function() use ( $table_name ) {
171+
$columns = new Column_Collection();
157172

158-
$columns[] = ( new Integer_Column( 'id' ) )->set_length( 11 )->set_signed( false )->set_type( Column::COLUMN_TYPE_INT );
159-
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
160-
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 );
173+
$columns[] = ( new Integer_Column( 'id' ) )->set_length( 11 )->set_signed( false )->set_type( Column::COLUMN_TYPE_INT );
174+
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
175+
$columns[] = ( new String_Column( 'slug' ) )->set_length( 25 );
176+
return new Table_Schema( $table_name, $columns );
177+
};
161178

162179
return [
163-
static::SCHEMA_VERSION => new Table_Schema( static::table_name( true ), $columns ),
180+
static::SCHEMA_VERSION => $callable,
164181
];
165182
}
166183

@@ -181,14 +198,18 @@ public function get_foreign_key_table() {
181198
protected static $schema_slug = 'bork-with-foreignkey';
182199

183200
public static function get_schema_history(): array {
184-
$columns = new Column_Collection();
201+
$table_name = static::table_name( true );
202+
$callable = function() use ( $table_name ) {
203+
$columns = new Column_Collection();
185204

186-
$columns[] = ( new Integer_Column( 'id' ) )->set_length( 11 )->set_signed( false )->set_type( Column::COLUMN_TYPE_INT );
187-
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
188-
$columns[] = ( new Integer_Column( 'simple_id' ) )->set_length( 11 )->set_signed( false )->set_type( Column::COLUMN_TYPE_INT );
205+
$columns[] = ( new Integer_Column( 'id' ) )->set_length( 11 )->set_signed( false )->set_type( Column::COLUMN_TYPE_INT );
206+
$columns[] = ( new String_Column( 'name' ) )->set_length( 25 );
207+
$columns[] = ( new Integer_Column( 'simple_id' ) )->set_length( 11 )->set_signed( false )->set_type( Column::COLUMN_TYPE_INT );
208+
return new Table_Schema( $table_name, $columns );
209+
};
189210

190211
return [
191-
static::SCHEMA_VERSION => new Table_Schema( static::table_name( true ), $columns ),
212+
static::SCHEMA_VERSION => $callable,
192213
];
193214
}
194215

0 commit comments

Comments
 (0)