@@ -18,7 +18,7 @@ public function forColumn_returns_required_rule_by_default()
18
18
{
19
19
$ column = new Column ('test ' , 'unknown ' );
20
20
21
- $ this ->assertEquals (['required ' ], Rules::fromColumn ($ column ));
21
+ $ this ->assertEquals (['required ' ], Rules::fromColumn (' context ' , $ column ));
22
22
}
23
23
24
24
/**
@@ -29,7 +29,7 @@ public function forColumn_returns_string_rule_for_string_data_types($data_type)
29
29
{
30
30
$ column = new Column ('test ' , $ data_type );
31
31
32
- $ this ->assertContains ('string ' , Rules::fromColumn ($ column ));
32
+ $ this ->assertContains ('string ' , Rules::fromColumn (' context ' , $ column ));
33
33
}
34
34
35
35
/**
@@ -39,11 +39,11 @@ public function forColumn_returns_max_rule_for_string_attributes()
39
39
{
40
40
$ column = new Column ('test ' , 'string ' , [], [1000 ]);
41
41
42
- $ this ->assertContains ('max:1000 ' , Rules::fromColumn ($ column ));
42
+ $ this ->assertContains ('max:1000 ' , Rules::fromColumn (' context ' , $ column ));
43
43
44
44
$ column = new Column ('test ' , 'char ' , [], [10 ]);
45
45
46
- $ this ->assertContains ('max:10 ' , Rules::fromColumn ($ column ));
46
+ $ this ->assertContains ('max:10 ' , Rules::fromColumn (' context ' , $ column ));
47
47
}
48
48
49
49
/**
@@ -54,13 +54,13 @@ public function forColumn_uses_email_rule_for_columns_named_email_or_email_addre
54
54
{
55
55
$ column = new Column ('email ' , $ data_type );
56
56
57
- $ this ->assertContains ('email ' , Rules::fromColumn ($ column ));
58
- $ this ->assertNotContains ('string ' , Rules::fromColumn ($ column ));
57
+ $ this ->assertContains ('email ' , Rules::fromColumn (' context ' , $ column ));
58
+ $ this ->assertNotContains ('string ' , Rules::fromColumn (' context ' , $ column ));
59
59
60
60
$ column = new Column ('email_address ' , $ data_type );
61
61
62
- $ this ->assertContains ('email ' , Rules::fromColumn ($ column ));
63
- $ this ->assertNotContains ('string ' , Rules::fromColumn ($ column ));
62
+ $ this ->assertContains ('email ' , Rules::fromColumn (' context ' , $ column ));
63
+ $ this ->assertNotContains ('string ' , Rules::fromColumn (' context ' , $ column ));
64
64
}
65
65
66
66
/**
@@ -71,8 +71,8 @@ public function forColumn_uses_password_rule_for_columns_named_password($data_ty
71
71
{
72
72
$ column = new Column ('password ' , $ data_type );
73
73
74
- $ this ->assertContains ('password ' , Rules::fromColumn ($ column ));
75
- $ this ->assertNotContains ('string ' , Rules::fromColumn ($ column ));
74
+ $ this ->assertContains ('password ' , Rules::fromColumn (' context ' , $ column ));
75
+ $ this ->assertNotContains ('string ' , Rules::fromColumn (' context ' , $ column ));
76
76
}
77
77
78
78
/**
@@ -83,7 +83,7 @@ public function forColumn_returns_numeric_rule_for_numeric_types($data_type)
83
83
{
84
84
$ column = new Column ('test ' , $ data_type );
85
85
86
- $ this ->assertContains ('numeric ' , Rules::fromColumn ($ column ));
86
+ $ this ->assertContains ('numeric ' , Rules::fromColumn (' context ' , $ column ));
87
87
}
88
88
89
89
/**
@@ -93,7 +93,7 @@ public function forColumn_returns_numeric_rule_for_numeric_types($data_type)
93
93
public function forColumn_returns_integer_rule_for_integer_types ($ data_type )
94
94
{
95
95
$ column = new Column ('test ' , $ data_type );
96
- $ this ->assertContains ('integer ' , Rules::fromColumn ($ column ));
96
+ $ this ->assertContains ('integer ' , Rules::fromColumn (' context ' , $ column ));
97
97
}
98
98
99
99
/**
@@ -104,7 +104,7 @@ public function forColumn_returns_exists_rule_for_foreign_keys($name, $table)
104
104
{
105
105
$ column = new Column ($ name , 'id ' );
106
106
107
- $ actual = Rules::fromColumn ($ column );
107
+ $ actual = Rules::fromColumn (' context ' , $ column );
108
108
109
109
$ this ->assertContains ('integer ' , $ actual );
110
110
$ this ->assertContains ("exists: {$ table },id " , $ actual );
@@ -117,11 +117,11 @@ public function forColumn_returns_gt0_rule_for_unsigned_numeric_types()
117
117
{
118
118
$ column = new Column ('test ' , 'integer ' );
119
119
120
- $ this ->assertNotContains ('gt:0 ' , Rules::fromColumn ($ column ));
120
+ $ this ->assertNotContains ('gt:0 ' , Rules::fromColumn (' context ' , $ column ));
121
121
122
122
$ column = new Column ('test ' , 'unsignedInteger ' );
123
123
124
- $ this ->assertContains ('gt:0 ' , Rules::fromColumn ($ column ));
124
+ $ this ->assertContains ('gt:0 ' , Rules::fromColumn (' context ' , $ column ));
125
125
}
126
126
127
127
/**
@@ -130,11 +130,11 @@ public function forColumn_returns_gt0_rule_for_unsigned_numeric_types()
130
130
public function forColumn_returns_in_rule_for_enums_and_sets ()
131
131
{
132
132
$ column = new Column ('test ' , 'enum ' , [], ['alpha ' , 'bravo ' , 'charlie ' ]);
133
- $ this ->assertContains ('in:alpha,bravo,charlie ' , Rules::fromColumn ($ column ));
133
+ $ this ->assertContains ('in:alpha,bravo,charlie ' , Rules::fromColumn (' context ' , $ column ));
134
134
135
135
$ column = new Column ('test ' , 'set ' , [], [2 , 4 , 6 ]);
136
136
137
- $ this ->assertContains ('in:2,4,6 ' , Rules::fromColumn ($ column ));
137
+ $ this ->assertContains ('in:2,4,6 ' , Rules::fromColumn (' context ' , $ column ));
138
138
}
139
139
140
140
/**
@@ -145,33 +145,17 @@ public function forColumn_returns_date_rule_for_date_types($data_type)
145
145
{
146
146
$ column = new Column ('test ' , $ data_type );
147
147
148
- $ this ->assertContains ('date ' , Rules::fromColumn ($ column ));
148
+ $ this ->assertContains ('date ' , Rules::fromColumn (' context ' , $ column ));
149
149
}
150
150
151
151
/**
152
152
* @test
153
- * @dataProvider stringDataTypesProvider
154
153
*/
155
- public function forColumn_does_not_return_unique_rule_for_the_unique_modifier_without_context ( $ data_type )
154
+ public function forColumn_return_exists_rule_for_the_unique_modifier ( )
156
155
{
157
- $ this ->markTestIncomplete ();
158
- $ column = new Column ('test ' , $ data_type , ['unique ' , 'nullable ' ]);
159
-
160
- $ this ->assertNotContains ('unique: ' , Rules::fromColumn ($ column ));
161
- }
162
-
163
- /**
164
- * @test
165
- */
166
- public function forColumn_returns_unique_rule_for_the_unique_modifier ()
167
- {
168
- $ this ->markTestIncomplete ();
169
- $ column = new Column ('test ' , 'string ' , ['unique ' ], [100 ]);
170
-
171
- $ actual = Rules::fromColumn ($ column , 'connection.table ' );
156
+ $ column = new Column ('column ' , 'string ' , ['unique ' ]);
172
157
173
- $ this ->assertContains ('unique:connection.table ' , $ actual );
174
- $ this ->assertContains ('max:100 ' , $ actual );
158
+ $ this ->assertContains ('unique:connection.table,column ' , Rules::fromColumn ('connection.table ' , $ column ));
175
159
}
176
160
177
161
public function stringDataTypesProvider ()
0 commit comments