Permalink
Browse files

fix tests and add new tests for many to many handle with isCrossref p…

…arameter
  • Loading branch information...
1 parent fc97215 commit d84cb0273b26e4a7c5b225fadd48d28e4a88c156 @jaugustin committed Mar 11, 2012
Showing with 35 additions and 1 deletion.
  1. +18 −1 test/functional/fixtures/config/schema.xml
  2. +17 −0 test/functional/formTest.php
@@ -46,7 +46,7 @@
<column name="hobbies" type="array" required="false" />
</table>
- <table name="author_article">
+ <table name="author_article" isCrossref="true">
<behavior name="symfony">
<parameter name="form" value="false"/>
<parameter name="filter" value="false"/>
@@ -150,4 +150,21 @@
<column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" />
<column name="enum_values" type="enum" valueSet="one, two, three space" />
</table>
+
+ <!-- model and data for testing many to many -->
+ <table name="seller">
+ <column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" />
+ <column name="name" type="varchar" size="255" />
+ </table>
+ <table name="sale">
+ <column name="seller_id" type="integer" primaryKey="true" />
+ <column name="book_id" type="integer" primaryKey="true" />
+ <column name="number" type="integer" />
+ <foreign-key foreignTable="seller">
+ <reference local="seller_id" foreign="id" />
+ </foreign-key>
+ <foreign-key foreignTable="book">
+ <reference local="book_id" foreign="id" />
+ </foreign-key>
+ </table>
</database>
@@ -291,3 +291,20 @@
checkElement('select option[selected="selected"]', 'three space')->
end()
;
+
+//Checks that many-to-many relations are generated correctly
+$form = new SellerForm();
+try {
+ $form->getWidget('sale_list');
+ $b->test()->fail('The seller form shoud not has sale_list field because it is not a many to many relation');
+} catch (InvalidArgumentException $e) {
+ $b->test()->pass('The seller form shoud not has sale_list field because it is not a many to many relation');
+}
+
+$form = new BookForm();
+try {
+ $form->getWidget('sale_list');
+ $b->test()->fail('The book form shoud not has sale_list field because it is not a many to many relation');
+} catch (InvalidArgumentException $e) {
+ $b->test()->pass('The book form shoud not has sale_list field because it is not a many to many relation');
+}

0 comments on commit d84cb02

Please sign in to comment.