Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix tests and add new tests for many to many handle with isCrossref p…
…arameter
  • Loading branch information
jaugustin committed Mar 11, 2012
1 parent fc97215 commit d84cb02
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/functional/fixtures/config/schema.xml
Expand Up @@ -46,7 +46,7 @@
<column name="hobbies" type="array" required="false" /> <column name="hobbies" type="array" required="false" />
</table> </table>


<table name="author_article"> <table name="author_article" isCrossref="true">
<behavior name="symfony"> <behavior name="symfony">
<parameter name="form" value="false"/> <parameter name="form" value="false"/>
<parameter name="filter" value="false"/> <parameter name="filter" value="false"/>
Expand Down Expand Up @@ -150,4 +150,21 @@
<column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" /> <column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" />
<column name="enum_values" type="enum" valueSet="one, two, three space" /> <column name="enum_values" type="enum" valueSet="one, two, three space" />
</table> </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> </database>
17 changes: 17 additions & 0 deletions test/functional/formTest.php
Expand Up @@ -291,3 +291,20 @@
checkElement('select option[selected="selected"]', 'three space')-> checkElement('select option[selected="selected"]', 'three space')->
end() 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.