99class TableTest extends SchemaTestCase {
1010 use Table_Fixtures;
1111
12+ /**
13+ * @before
14+ */
15+ public function drop_tables () {
16+ $ this ->get_simple_table ()->drop ();
17+ $ this ->get_foreign_key_table ()->drop ();
18+ }
19+
1220 /**
1321 * Should have index.
1422 *
1523 * @test
1624 */
1725 public function should_have_index () {
18- $ table = $ this ->get_simple_table ();
26+ $ table = $ this ->get_simple_table ();
1927
2028 Register::table ( $ table );
2129
@@ -28,11 +36,45 @@ public function should_have_index() {
2836 * @test
2937 */
3038 public function should_have_fake_index () {
31- $ table = $ this ->get_simple_table ();
39+ $ table = $ this ->get_simple_table ();
3240
3341 Register::table ( $ table );
3442
3543 $ this ->assertFalse ( $ table ->has_index ( 'bork ' ) );
3644 }
45+
46+ /**
47+ * It should not have foreign key
48+ *
49+ * @test
50+ */
51+ public function should_not_have_foreign_key () {
52+ $ simple_table = $ this ->get_simple_table ();
53+ $ foreign_key_table = $ this ->get_foreign_key_table ();
54+
55+ Register::table ( $ simple_table );
56+ Register::table ( $ foreign_key_table );
57+
58+ $ this ->assertFalse ( $ simple_table ->has_foreign_key ( 'simple_id ' ) );
59+ $ this ->assertFalse ( $ foreign_key_table ->has_foreign_key ( 'not_really ' ) );
60+ }
61+
62+ /**
63+ * It should have foreign key
64+ *
65+ * @test
66+ */
67+ public function should_have_foreign_key () {
68+ $ simple_table = $ this ->get_simple_table ();
69+ $ foreign_key_table = $ this ->get_foreign_key_table ();
70+
71+ Register::table ( $ simple_table );
72+ Register::table ( $ foreign_key_table );
73+
74+ $ this ->assertFalse ( $ simple_table ->has_foreign_key ( 'simple_id ' ) );
75+ $ this ->assertFalse ( $ foreign_key_table ->has_foreign_key ( 'not_really ' ) );
76+
77+ $ this ->assertTrue ( $ foreign_key_table ->has_foreign_key ( 'simple_id ' ) );
78+ }
3779}
3880
0 commit comments