GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
sqlmarker
Browse code
- Switched to new (il)legal value tests.
master
1 parent
f364ad4
commit
e7feda5552dbd662521b962d0a27dd41a0e90ba8
Nigel Stanger
authored
on 25 Jun 2013
Patch
Showing
2 changed files
Unit_testing/BDL_Test_Staff.php
Unit_testing/BDL_Test_Staff_data.php
Ignore Space
Show notes
View
Unit_testing/BDL_Test_Staff.php
<?php require_once "Schema.php"; abstract class BDL_Test_Staff extends PHPUnit_Extensions_Database_TestCase_CreateTable { public function getTableName() { return 'STAFF'; } public function getColumnList() { return array( 'STAFF_ID' => array( 'generic_type' => 'NUMBER', 'sql_type' => array( 'NUMBER', 'INTEGER' ), 'min_length' => 7, 'max_length' => 7, 'decimals' => 0, // 'underflow' => -1, 'nullable' => false, 'test_value' => "123456", ), 'SURNAME' => array( 'generic_type' => 'TEXT', 'sql_type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 50, 'max_length' => 50, 'nullable' => false, 'test_value' => "Bloggs", ), 'FIRSTNAMES' => array( 'generic_type' => 'TEXT', 'sql_type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 50, 'max_length' => 50, 'nullable' => false, 'test_value' => "Harold", ), 'PHONE' => array( 'generic_type' => 'TEXT', 'sql_type' => array( 'VARCHAR2', 'CHAR', 'VARCHAR' ), 'min_length' => 11, 'max_length' => 20, 'nullable' => false, 'test_value' => "16139981234", ), 'ADDRESS' => array( 'generic_type' => 'TEXT', 'sql_type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 150, 'max_length' => 150, 'nullable' => false, 'test_value' => "12 Western Way", ), 'DEPARTMENT' => array( 'generic_type' => 'TEXT', 'sql_type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 18, 'max_length' => 25, 'nullable' => false, 'legal_values' => array( "Central Management", "Sales & Marketing", "Personnel", "Manufacturing", "Inventory", "Accounts" ), 'illegal_values' => array( "Sales and Marketing", "foobar", "blurk", " " ), 'test_value' => "Accounts", ), 'POSITION' => array( 'generic_type' => 'TEXT', 'sql_type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 20, 'max_length' => 30, 'nullable' => false, 'legal_values' => array( "CEO", "CTO", "CFO", "CIO", "Director", "President", "Vice-President", "Manager", "Personal Assistant", "Secretary", "Technician", "Researcher", "Designer", "Assembler", "Programmer", "Contractor", "Sales Representative", "Accountant", "Inventory", "Assistant" ), 'illegal_values' => array( "barfoo", "blargh", " " ), 'test_value' => "CEO", ), 'SALARY' => array( 'generic_type' => 'NUMBER', 'sql_type' => array( 'NUMBER', 'DECIMAL' ), 'min_length' => 7, 'max_length' => 7, 'decimals' => 2, 'underflow' => "999.99", 'overflow' => "100000", 'nullable' => false, 'test_value' => "50000", ), 'COMMENTS' => array( 'generic_type' => 'TEXT', 'sql_type' => array( 'VARCHAR2', 'CLOB' ), 'min_length' => 500, 'max_length' => 4000, 'nullable' => true, 'test_value' => "Blah blah blah", ), ); } public function getPKColumnList() { return array( 'STAFF_ID' ); } public function getFKColumnList() { return array(); } } ?>
<?php require_once "Schema.php"; abstract class BDL_Test_Staff extends PHPUnit_Extensions_Database_TestCase_CreateTable { public function getTableName() { return 'STAFF'; } public function getColumnList() { return array( 'STAFF_ID' => array( 'type' => array( 'NUMBER', 'INTEGER' ), 'min_length' => 7, 'max_length' => 7, 'decimals' => 0, // 'underflow' => -1, 'nullable' => false, 'test_value' => "123456", ), 'SURNAME' => array( 'type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 50, 'max_length' => 50, 'nullable' => false, 'test_value' => "'Bloggs'", ), 'FIRSTNAMES' => array( 'type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 50, 'max_length' => 50, 'nullable' => false, 'test_value' => "'Harold'", ), 'PHONE' => array( 'type' => array( 'VARCHAR2', 'CHAR', 'VARCHAR' ), 'min_length' => 11, 'max_length' => 25, 'nullable' => false, 'test_value' => "'16139981234'", ), 'ADDRESS' => array( 'type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 150, 'max_length' => 150, 'nullable' => false, 'test_value' => "'12 Western Way'", ), 'DEPARTMENT' => array( 'type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 18, 'max_length' => 20, 'nullable' => false, 'legal_values' => array( "'Central Management'", "'Sales ' || chr(38) || ' Marketing'", "'Personnel'", "'Manufacturing'", "'Inventory'", "'Accounts'" ), 'illegal_values' => array( "'foobar'", "'blurk'", "' '" ), 'test_value' => "'Accounts'", ), 'POSITION' => array( 'type' => array( 'VARCHAR2', 'VARCHAR' ), 'min_length' => 20, 'max_length' => 20, 'nullable' => false, 'legal_values' => array( "'CEO'", "'CTO'", "'CFO'", "'CIO'", "'Director'", "'President'", "'Vice-President'", "'Manager'", "'Personal Assistant'", "'Secretary'", "'Technician'", "'Researcher'", "'Designer'", "'Assembler'", "'Programmer'", "'Contractor'", "'Sales Representative'", "'Accountant'", "'Inventory'", "'Assistant'" ), 'illegal_values' => array( "'foobar'", "'blurk'", "' '" ), 'test_value' => "'CEO'", ), 'SALARY' => array( 'type' => array( 'NUMBER', 'DECIMAL' ), 'min_length' => 7, 'max_length' => 7, 'decimals' => 2, 'underflow' => 999.99, 'overflow' => 100000.00, 'nullable' => false, 'test_value' => "50000.00", ), 'COMMENTS' => array( 'type' => array( 'VARCHAR2', 'CLOB' ), 'min_length' => 1000, 'max_length' => 4000, 'nullable' => true, 'test_value' => "'Blah blah blah'", ), ); } public function getPKColumnList() { return array( 'STAFF_ID' ); } public function getFKColumnList() { return array(); } } ?>
Ignore Space
Show notes
View
Unit_testing/BDL_Test_Staff_data.php
<?php require_once "BDL_Test_Staff.php"; class BDL_Test_Staff_data extends BDL_Test_Staff { /** * Return fixture data set for current database connection. * * @access protected * @return PHPUnit_Extensions_Database_DataSet_IDataSet * @todo Parameterise the fixture filename. */ protected function getDataSet() { return $this->createXMLDataSet("BDL_Fixture_Staff.xml"); } /** * @dataProvider provideColumnLegalValues */ public function testColumnLegalValue( $columnName, $legalValue ) { $this->assertColumnLegalValue( $columnName, $legalValue ); } /** * @dataProvider provideColumnIllegalValues * @expectedException PDOException * @expectedExceptionMessage check constraint * @expectedExceptionCode HY000 */ public function testColumnIllegalValueExplicit( $columnName, $illegalValue ) { $this->assertColumnIllegalValueExplicit( $columnName, $illegalValue ); } /** * @dataProvider provideColumnIllegalValues * @expectedException PDOException * @expectedExceptionMessage length exceeded * @expectedExceptionCode HY000 */ public function testColumnIllegalValueImplicit( $columnName, $illegalValue ) { $this->assertColumnIllegalValueImplicit( $columnName, $illegalValue ); } /** * @dataProvider provideColumnUnderflowValues * @expectedException PDOException * @expectedExceptionMessage check constraint * @expectedExceptionCode HY000 */ public function testColumnUnderflowValue( $columnName, $underflowValue ) { $this->assertColumnUnderflowValue( $columnName, $underflowValue ); } /** * @dataProvider provideColumnOverflowValues * @expectedException PDOException * @expectedExceptionMessage check constraint * @expectedExceptionCode HY000 */ public function testColumnOverflowValueExplicit( $columnName, $overflowValue ) { $this->assertColumnOverflowValueExplicit( $columnName, $overflowValue ); } /** * @dataProvider provideColumnOverflowValues * @expectedException PDOException * @expectedExceptionMessage length exceeded * @expectedExceptionCode HY000 */ public function testColumnOverflowValueImplicit( $columnName, $overflowValue ) { $this->assertColumnOverflowValueImplicit( $columnName, $overflowValue ); } } ?>
<?php require_once "BDL_Test_Staff.php"; class BDL_Test_Staff_data extends BDL_Test_Staff { /** * Return fixture data set for current database connection. * * @access protected * @return PHPUnit_Extensions_Database_DataSet_IDataSet * @todo Parameterise the fixture filename. */ protected function getDataSet() { return $this->createXMLDataSet("BDL_Fixture_Staff.xml"); } /** * @dataProvider provideColumnLegalValues */ public function testColumnLegalValue( $columnName, $legalValue ) { $this->assertColumnLegalValue( $columnName, $legalValue ); } /** * @dataProvider provideColumnIllegalValues * @expectedException PDOException * @expectedExceptionMessage check constraint * @expectedExceptionCode HY000 */ public function testColumnIllegalValue( $columnName, $illegalValue ) { $this->assertColumnIllegalValue( $columnName, $illegalValue ); } /** * @dataProvider provideColumnUnderflowValues * @expectedException PDOException * @expectedExceptionMessage check constraint * @expectedExceptionCode HY000 */ public function testColumnUnderflowValue( $columnName, $underflowValue ) { $this->assertColumnUnderflowValue( $columnName, $underflowValue ); } /** * @dataProvider provideColumnOverflowValues * @expectedException PDOException * @expectedExceptionMessage check constraint * @expectedExceptionCode HY000 */ public function testColumnOverflowValue( $columnName, $overflowValue ) { $this->assertColumnOverflowValue( $columnName, $overflowValue ); } } ?>
Show line notes below