2
0

StaticTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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-2015 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. /**
  26. * @see Zend_Db_Table_Row_TestMockRow
  27. */
  28. require_once dirname(__FILE__) . '/../_files/My/ZendDbTable/Row/TestMockRow.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Db
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. * @group Zend_Db
  36. * @group Zend_Db_Table
  37. * @group Zend_Db_Table_Relationships
  38. */
  39. class Zend_Db_Table_Relationships_StaticTest extends PHPUnit_Framework_TestCase
  40. {
  41. public function testTableRelationshipsFindDependentMagic()
  42. {
  43. $row = new My_ZendDbTable_Row_TestMockRow();
  44. $this->assertNull($row->dependentTable);
  45. $this->assertNull($row->ruleKey);
  46. $row->findTable1();
  47. $this->assertEquals('Table1', $row->dependentTable);
  48. $this->assertNull($row->ruleKey);
  49. $row->findTable2ByRule1();
  50. $this->assertEquals('Table2', $row->dependentTable);
  51. $this->assertEquals('Rule1', $row->ruleKey);
  52. }
  53. public function testTableRelationshipsFindParentMagic()
  54. {
  55. $row = new My_ZendDbTable_Row_TestMockRow();
  56. $this->assertNull($row->parentTable);
  57. $this->assertNull($row->ruleKey);
  58. $row->findParentTable1();
  59. $this->assertEquals('Table1', $row->parentTable);
  60. $this->assertNull($row->ruleKey);
  61. $row->findParentTable2ByRule1();
  62. $this->assertEquals('Table2', $row->parentTable);
  63. $this->assertEquals('Rule1', $row->ruleKey);
  64. }
  65. public function testTableRelationshipsFindManyToManyMagic()
  66. {
  67. $row = new My_ZendDbTable_Row_TestMockRow();
  68. $this->assertNull($row->matchTable);
  69. $this->assertNull($row->intersectionTable);
  70. $this->assertNull($row->callerRefRuleKey);
  71. $this->assertNull($row->matchRefRuleKey);
  72. $row->findTable1ViaTable2();
  73. $this->assertEquals('Table1', $row->matchTable);
  74. $this->assertEquals('Table2', $row->intersectionTable);
  75. $this->assertNull($row->callerRefRuleKey);
  76. $this->assertNull($row->matchRefRuleKey);
  77. $row->findTable3ViaTable4ByRule1();
  78. $this->assertEquals('Table3', $row->matchTable);
  79. $this->assertEquals('Table4', $row->intersectionTable);
  80. $this->assertEquals('Rule1', $row->callerRefRuleKey);
  81. $this->assertNull($row->matchRefRuleKey);
  82. $row->findTable5ViaTable6ByRule2AndRule3();
  83. $this->assertEquals('Table5', $row->matchTable);
  84. $this->assertEquals('Table6', $row->intersectionTable);
  85. $this->assertEquals('Rule2', $row->callerRefRuleKey);
  86. $this->assertEquals('Rule3', $row->matchRefRuleKey);
  87. }
  88. public function getDriver()
  89. {
  90. return 'Static';
  91. }
  92. }