Zend Db Unit Test failed truncation attempt

Basically, my test failed because of an "integrity violation" when trying to TRUNCATE tables in a bad order.

Each Db test case extends PHPUnit_DatabaseTestCase_Abstract, which trims tables before testing. As soon as I have a line in the Property, all tests failed due to an error: COMPOSITE [TRUNCATE] operation failed in the request.

This is my database schema:

-- -----------------------------------------------------
-- Table `project`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `project` (
  `project_id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`project_id`) ,
  UNIQUE INDEX `project_id_UNIQUE` (`project_id` ASC) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `customer`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `customer` (
  `customer_id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `firstname` VARCHAR(45) NOT NULL ,
  `lastname` VARCHAR(45) NOT NULL ,
  `email` VARCHAR(45) NOT NULL ,
  `telephone` VARCHAR(45) NULL DEFAULT NULL ,
  PRIMARY KEY (`customer_id`) ,
  UNIQUE INDEX `customer_id_UNIQUE` (`customer_id` ASC) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `property`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `property` (
  `property_id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `project_id` INT UNSIGNED NOT NULL ,
  `customer_id` INT UNSIGNED NULL DEFAULT NULL ,
  `name` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`property_id`) ,
  UNIQUE INDEX `property_id_UNIQUE` (`property_id` ASC) ,
  INDEX `fk_property_project` (`project_id` ASC) ,
  INDEX `fk_property_customer1` (`customer_id` ASC) ,
  CONSTRAINT `fk_property_project`
    FOREIGN KEY (`project_id` )
    REFERENCES `project` (`project_id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_property_customer1`
    FOREIGN KEY (`customer_id` )
    REFERENCES `customer` (`customer_id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

Am I testing wrong? How can I specify truncation in the correct order before testing?

Zend Version 1.11.5

The error is assumed to be fixed (check the zend forum framework

+3
source share
1 answer

phpunit , , ZF: Zend_Test_PHPUnit_DatabaseTestCase PHPUnit_DatabaseTestCase_Abstract. , .

+1

All Articles