-
-
Save doctrinebot/bf11a908ac1d309efd6c to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-732 - https://github.com/doctrine/doctrine2/issues/5245
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- MySQL Administrator dump 1.4 | |
-- | |
-- ------------------------------------------------------ | |
-- Server version 5.0.51a-24+lenny3-log | |
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | |
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | |
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | |
/*!40101 SET NAMES utf8 */; | |
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | |
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | |
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | |
-- | |
-- Create schema crm | |
-- | |
CREATE DATABASE IF NOT EXISTS test; | |
USE test; | |
-- | |
-- Definition of table `test`.`Contacts` | |
-- | |
DROP TABLE IF EXISTS `test`.`Contacts`; | |
CREATE TABLE `test`.`Contacts` ( | |
`contactID` int(11) NOT NULL auto_increment, | |
`name` varchar(255) NOT NULL, | |
`identity` varchar(50) default NULL, | |
`contactType` enum('PERSON','EMPLOYEE','DRIVER') NOT NULL default 'PERSON', | |
PRIMARY KEY (`contactID`), | |
KEY `contact_num` (`identity`), | |
KEY `contact_type` (`contactType`) | |
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8; | |
-- | |
-- Definition of table `test`.`Persons` | |
-- | |
DROP TABLE IF EXISTS `test`.`Persons`; | |
CREATE TABLE `test`.`Persons` ( | |
`contactID` int(11) NOT NULL, | |
`firstName` varchar(100) NOT NULL, | |
`lastName` varchar(100) NOT NULL, | |
`birthDate` date default NULL, | |
PRIMARY KEY (`contactID`), | |
KEY `person_contact` (`contactID`), | |
CONSTRAINT `person_contact` FOREIGN KEY (`contactID`) REFERENCES `Contacts` (`contactID`) ON DELETE NO ACTION ON UPDATE NO ACTION | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
-- | |
-- Definition of table `test`.`Employees` | |
-- | |
DROP TABLE IF EXISTS `test`.`Employees`; | |
CREATE TABLE `test`.`Employees` ( | |
`contactID` int(11) NOT NULL, | |
`PN` varchar(5) NOT NULL, | |
PRIMARY KEY (`contactID`), | |
KEY `employee_person` (`contactID`), | |
CONSTRAINT `employee_person` FOREIGN KEY (`contactID`) REFERENCES `Persons` (`contactID`) ON DELETE NO ACTION ON UPDATE NO ACTION | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
DROP TABLE IF EXISTS `test`.`Driver`; | |
CREATE TABLE `test`.`Driver` ( | |
`contactID` int(11) NOT NULL, | |
`Licens` varchar(5) NOT NULL, | |
PRIMARY KEY (`contactID`), | |
KEY `driver_employee` (`contactID`), | |
CONSTRAINT `driver_employee` FOREIGN KEY (`contactID`) REFERENCES `Employees` (`contactID`) ON DELETE NO ACTION ON UPDATE NO ACTION | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | |
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | |
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | |
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | |
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | |
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | |
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Doctrine\Tests\ORM\Functional\Ticket; | |
require_once __DIR__ . '/../../../TestInit.php'; | |
class DDC732Test extends \Doctrine\Tests\OrmFunctionalTestCase | |
{ | |
protected function setUp() | |
{ | |
parent::setUp(); | |
try { | |
$this->_schemaTool->createSchema(array( | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC732Contacts'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC732Person'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC732Employee'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC732Driver'), | |
)); | |
} catch(\Exception $e) { | |
} | |
} | |
public function testInsertInheritedOne() | |
{ | |
$person = new DDC732Person; | |
$person->setContactId(0); | |
$person->setName('test2'); | |
$person->setIdentity('test2'); | |
$person->setFirstName('Test2'); | |
$person->setLastName('Test2'); | |
$this->_em->persist($person); | |
$this->_em->flush(); | |
echo 'Ok saved'; | |
} | |
public function testInsertInheritedTwo() | |
{ | |
$employee = new DDC732Employee; | |
$employee->setContactId(0); | |
$employee->setName('test2'); | |
$employee->setIdentity('test2'); | |
$employee->setFirstName('Test2'); | |
$employee->setLastName('Test2'); | |
$employee->setPN('AL'); | |
$this->_em->persist($employee); | |
$this->_em->flush(); | |
echo 'Ok saved'; | |
} | |
public function testInsertInheritedThree() | |
{ | |
$driver = new DDC732Driver; | |
$driver->setContactId(0); | |
$driver->setName('test2'); | |
$driver->setIdentity('test2'); | |
$driver->setFirstName('Test2'); | |
$driver->setLastName('Test2'); | |
$driver->setPN('AL'); | |
$driver->setLicense('testL'); | |
$this->_em->persist($driver); | |
$this->_em->flush(); | |
echo 'Ok saved'; | |
} | |
} | |
/** | |
* | |
* @Entity | |
* @InheritanceType("JOINED") | |
* @Table(name="Contacts") | |
* @DiscriminatorColumn(name="contactType", type="string") | |
* @DiscriminatorMap({"PERSON" = "Person", "EMPLOYEE" = "Employee", "DRIVER" = "Driver"}) | |
*/ | |
class DDC732Contacts | |
{ | |
/** | |
* @Id @Column(name="contactID", type="integer") | |
* @GeneratedValue(strategy="AUTO") | |
* | |
*/ | |
protected $contactID; | |
/** | |
* @Column(name="name", type="string", length="255") | |
* | |
* | |
*/ | |
protected $name; | |
/** | |
* @Column(name="identity", type="string", length="50") | |
* | |
* | |
*/ | |
protected $identity; | |
public function setContactID($data) { | |
$this->contactID = $data | |
} | |
public function setName($data) { | |
$this->name = $data | |
} | |
public function setIdentity($data) { | |
$this->identity = $data | |
} | |
} | |
/** | |
* @Table(name="Persons") | |
* @entity | |
*/ | |
class DDC732Person extends DDC732Contacts | |
{ | |
/** | |
* @Column(name="firstName", type="string", length="100") | |
* | |
* | |
*/ | |
protected $firstName; | |
/** | |
* @Column(name="lastName", type="string", length="100") | |
* | |
* | |
*/ | |
protected $lastName; | |
/** | |
* @Column(name="birthDate", type="date") | |
* | |
* | |
*/ | |
protected $birthDate; | |
public function setFirstName($data) { | |
$this->firstName = $data | |
} | |
public function setLastName($data) { | |
$this->lastName = $data | |
} | |
} | |
/** | |
* | |
* @Table(name="Employees") | |
* @entity | |
*/ | |
class DDC732Employee extends DDC732Person | |
{ | |
/** | |
* @Column(name="PN", type="string", length="5") | |
* | |
* | |
*/ | |
protected $PN; | |
public function setPN($data) { | |
$this->PN = $data | |
} | |
} | |
/** | |
* | |
* @Table(name="Driver") | |
* @entity | |
*/ | |
class DDC732Driver extends DDC732Employee | |
{ | |
/** | |
* @Column(name="License", type="string", length="5") | |
* | |
* | |
*/ | |
protected $license; | |
public function setLicense($data) { | |
$this->license = $data | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment