@@ -84,6 +84,22 @@ test(function () {
8484});
8585
8686
87+ test (function () {
88+ Assert::exception (function () {
89+ $ table = new Table ('book ' );
90+ $ table ->removeColumn ('id ' );
91+
92+ }, CzProject \SqlSchema \MissingException::class, "Column 'id' in table 'book' not exists. " );
93+
94+ $ table = new Table ('book ' );
95+ $ column = $ table ->addColumn ('id ' , 'INT ' );
96+ Assert::same (1 , count ($ table ->getColumns ()));
97+
98+ $ table ->removeColumn ($ column );
99+ Assert::same (0 , count ($ table ->getColumns ()));
100+ });
101+
102+
87103test (function () {
88104 Assert::exception (function () {
89105 $ table = new Table ('book ' );
@@ -101,6 +117,22 @@ test(function () {
101117});
102118
103119
120+ test (function () {
121+ Assert::exception (function () {
122+ $ table = new Table ('book ' );
123+ $ table ->removeIndex ('id ' );
124+
125+ }, CzProject \SqlSchema \MissingException::class, "Index 'id' in table 'book' not exists. " );
126+
127+ $ table = new Table ('book ' );
128+ $ index = $ table ->addIndex ('id ' , Index::TYPE_INDEX );
129+ Assert::same (1 , count ($ table ->getIndexes ()));
130+
131+ $ table ->removeIndex ($ index );
132+ Assert::same (0 , count ($ table ->getIndexes ()));
133+ });
134+
135+
104136test (function () {
105137 Assert::exception (function () {
106138 $ table = new Table ('book ' );
@@ -116,3 +148,19 @@ test(function () {
116148
117149 }, CzProject \SqlSchema \DuplicateException::class, "Foreign key 'author_id' in table 'book' already exists. " );
118150});
151+
152+
153+ test (function () {
154+ Assert::exception (function () {
155+ $ table = new Table ('book ' );
156+ $ table ->removeForeignKey ('author_id ' );
157+
158+ }, CzProject \SqlSchema \MissingException::class, "Foreign key 'author_id' in table 'book' not exists. " );
159+
160+ $ table = new Table ('book ' );
161+ $ foreignKey = $ table ->addForeignKey ('author_id ' , [], 'author ' );
162+ Assert::same (1 , count ($ table ->getForeignKeys ()));
163+
164+ $ table ->removeForeignKey ($ foreignKey );
165+ Assert::same (0 , count ($ table ->getForeignKeys ()));
166+ });
0 commit comments