StaticTest.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Db
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * PHPUnit_Framework_TestCase
  24. */
  25. require_once 'PHPUnit/Framework/TestCase.php';
  26. /**
  27. * PHPUnit_Util_Filter
  28. */
  29. require_once 'PHPUnit/Util/Filter.php';
  30. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  31. /**
  32. * @see Zend_Db_Table_Row_TestMockRow
  33. */
  34. require_once dirname(__FILE__) . '/../_files/My/ZendDbTable/Row/TestMockRow.php';
  35. /**
  36. * @category Zend
  37. * @package Zend_Db
  38. * @subpackage UnitTests
  39. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. * @group Zend_Db
  42. * @group Zend_Db_Table
  43. * @group Zend_Db_Table_Relationships
  44. */
  45. class Zend_Db_Table_Relationships_StaticTest extends PHPUnit_Framework_TestCase
  46. {
  47. public function testTableRelationshipsFindDependentMagic()
  48. {
  49. $row = new My_ZendDbTable_Row_TestMockRow();
  50. $this->assertNull($row->dependentTable);
  51. $this->assertNull($row->ruleKey);
  52. $row->findTable1();
  53. $this->assertEquals('Table1', $row->dependentTable);
  54. $this->assertNull($row->ruleKey);
  55. $row->findTable2ByRule1();
  56. $this->assertEquals('Table2', $row->dependentTable);
  57. $this->assertEquals('Rule1', $row->ruleKey);
  58. }
  59. public function testTableRelationshipsFindParentMagic()
  60. {
  61. $row = new My_ZendDbTable_Row_TestMockRow();
  62. $this->assertNull($row->parentTable);
  63. $this->assertNull($row->ruleKey);
  64. $row->findParentTable1();
  65. $this->assertEquals('Table1', $row->parentTable);
  66. $this->assertNull($row->ruleKey);
  67. $row->findParentTable2ByRule1();
  68. $this->assertEquals('Table2', $row->parentTable);
  69. $this->assertEquals('Rule1', $row->ruleKey);
  70. }
  71. public function testTableRelationshipsFindManyToManyMagic()
  72. {
  73. $row = new My_ZendDbTable_Row_TestMockRow();
  74. $this->assertNull($row->matchTable);
  75. $this->assertNull($row->intersectionTable);
  76. $this->assertNull($row->callerRefRuleKey);
  77. $this->assertNull($row->matchRefRuleKey);
  78. $row->findTable1ViaTable2();
  79. $this->assertEquals('Table1', $row->matchTable);
  80. $this->assertEquals('Table2', $row->intersectionTable);
  81. $this->assertNull($row->callerRefRuleKey);
  82. $this->assertNull($row->matchRefRuleKey);
  83. $row->findTable3ViaTable4ByRule1();
  84. $this->assertEquals('Table3', $row->matchTable);
  85. $this->assertEquals('Table4', $row->intersectionTable);
  86. $this->assertEquals('Rule1', $row->callerRefRuleKey);
  87. $this->assertNull($row->matchRefRuleKey);
  88. $row->findTable5ViaTable6ByRule2AndRule3();
  89. $this->assertEquals('Table5', $row->matchTable);
  90. $this->assertEquals('Table6', $row->intersectionTable);
  91. $this->assertEquals('Rule2', $row->callerRefRuleKey);
  92. $this->assertEquals('Rule3', $row->matchRefRuleKey);
  93. }
  94. public function getDriver()
  95. {
  96. return 'Static';
  97. }
  98. }