Newer
Older
sqlmarker / Unit_testing / BDL_Test_Order_head.php
  1. <?php
  2. require_once "Schema.php";
  3.  
  4. class BDL_Test_Order_head extends PHPUnit_Extensions_Database_TestCase_CreateTable
  5. {
  6. public function getTableName()
  7. {
  8. return 'ORDER_HEAD';
  9. }
  10. public function getColumnList()
  11. {
  12. return array(
  13. 'ORDER_NUM' => array( 'type' => array( 'NUMBER', 'INTEGER' ),
  14. 'min_length' => 10,
  15. 'max_length' => 10,
  16. 'decimals' => 0,
  17. // 'underflow' => -1,
  18. 'nullable' => false,
  19. 'test_value' => "8765432109", ),
  20. 'ORDER_DATE' => array( 'type' => array( 'DATE' ),
  21. 'nullable' => false,
  22. 'overflow' => "SYSDATE + 1",
  23. 'test_value' => "TO_DATE( '2012-10-22', 'YYYY-MM-DD')", ),
  24. 'DUE_DATE' => array( 'type' => array( 'DATE' ),
  25. 'nullable' => false,
  26. 'underflow' => "TO_DATE( '2012-10-21', 'YYYY-MM-DD')",
  27. 'test_value' => "TO_DATE( '2012-10-23', 'YYYY-MM-DD')", ),
  28. 'STATUS' => array( 'type' => array( 'VARCHAR2', 'VARCHAR' ),
  29. 'min_length' => 11,
  30. 'max_length' => 15,
  31. 'nullable' => false,
  32. 'legal_values' => array( "'complete'", "'in progress'" ),
  33. 'illegal_values' => array( "'foobar'", "'blurk'", "' '" ),
  34. 'test_value' => "'complete'", ),
  35. 'SUPPLIER_ID' => array( 'type' => array( 'NUMBER', 'INTEGER' ),
  36. 'min_length' => 7,
  37. 'max_length' => 7,
  38. 'decimals' => 0,
  39. 'nullable' => false,
  40. 'test_value' => "1", ),
  41. 'STAFF_ID' => array( 'type' => array( 'NUMBER', 'INTEGER' ),
  42. 'min_length' => 7,
  43. 'max_length' => 7,
  44. 'decimals' => 0,
  45. 'nullable' => false,
  46. 'test_value' => "326", ),
  47. 'COMMENTS' => array( 'type' => array( 'VARCHAR2', 'CLOB' ),
  48. 'min_length' => 1000,
  49. 'max_length' => 4000,
  50. 'nullable' => true,
  51. 'test_value' => "'Blah blah blah'", ), );
  52. }
  53. public function getPKColumnList()
  54. {
  55. return array( 'ORDER_NUM' );
  56. }
  57. public function getFKColumnList()
  58. {
  59. return array(
  60. 'STAFF' => array( 'STAFF_ID' ),
  61. 'SUPPLIER' => array( 'SUPPLIER_ID' ),
  62. );
  63. }
  64. /**
  65. * Return fixture data set for current database connection.
  66. *
  67. * @access protected
  68. * @return PHPUnit_Extensions_Database_DataSet_IDataSet
  69. * @todo Parameterise the fixture filename.
  70. */
  71. protected function getDataSet()
  72. {
  73. return $this->createXMLDataSet("BDL_Fixture_Order_head.xml");
  74. }
  75. public function testTableExists()
  76. {
  77. $this->assertTableExists();
  78. }
  79. /**
  80. * @dataProvider provideColumnNames
  81. */
  82. public function testColumnExists( $columnName )
  83. {
  84. $this->assertColumnExists( $columnName );
  85. }
  86. /**
  87. * @dataProvider provideColumnTypes
  88. */
  89. public function testColumnDataType( $columnName, $columnTypeList )
  90. {
  91. $this->assertColumnDataType( $columnName, $columnTypeList );
  92. }
  93. /**
  94. * @dataProvider provideColumnLengths
  95. */
  96. public function testColumnLength( $columnName, $columnLengthList )
  97. {
  98. $this->assertColumnLength( $columnName, $columnLengthList );
  99. }
  100. /**
  101. * @dataProvider provideColumnLegalValues
  102. */
  103. public function testColumnLegalValue( $columnName, $legalValue )
  104. {
  105. $this->assertColumnLegalValue( $columnName, $legalValue );
  106. }
  107. /**
  108. * @dataProvider provideColumnIllegalValues
  109. * @expectedException PDOException
  110. * @expectedExceptionMessage check constraint
  111. * @expectedExceptionCode HY000
  112. */
  113. public function testColumnIllegalValue( $columnName, $illegalValue )
  114. {
  115. $this->assertColumnIllegalValue( $columnName, $illegalValue );
  116. }
  117. /**
  118. * @dataProvider provideColumnUnderflowValues
  119. * @expectedException PDOException
  120. * @expectedExceptionMessage check constraint
  121. * @expectedExceptionCode HY000
  122. */
  123. public function testColumnUnderflowValue( $columnName, $underflowValue )
  124. {
  125. $this->assertColumnUnderflowValue( $columnName, $underflowValue );
  126. }
  127. /**
  128. * @dataProvider provideColumnOverflowValues
  129. * @expectedException PDOException
  130. * @expectedExceptionMessage check constraint
  131. * @expectedExceptionCode HY000
  132. */
  133. public function testColumnOverflowValue( $columnName, $overflowValue )
  134. {
  135. $this->assertColumnOverflowValue( $columnName, $overflowValue );
  136. }
  137. /**
  138. * @dataProvider provideColumnNullabilities
  139. */
  140. public function testColumnNullability( $columnName, $columnNullability )
  141. {
  142. $this->assertColumnNullability( $columnName, $columnNullability );
  143. }
  144. public function testPKExists()
  145. {
  146. return $this->assertPKExists();
  147. }
  148. /**
  149. * @depends testPKExists
  150. */
  151. public function testPKColumns( $constraintName )
  152. {
  153. $this->assertPKColumns( $constraintName );
  154. }
  155. /**
  156. * @dataProvider provideFKReferencedTables
  157. */
  158. public function testFKsExist( $referencedTableName )
  159. {
  160. return $this->assertFKsExist( $referencedTableName );
  161. }
  162. /**
  163. * @dataProvider provideFKReferencedTables
  164. */
  165. public function testFKColumns( $referencedTableName )
  166. {
  167. $this->assertFKColumns( $referencedTableName );
  168. }
  169. /**
  170. * @dataProvider provideConstraintNames
  171. */
  172. public function testConstraintsNamed( $constraintName, $constraintType )
  173. {
  174. $this->assertConstraintNamed( $constraintName, $constraintType );
  175. }
  176. }
  177. ?>