public function testValidationConstraints() { // Validations $kittenType = "kitten"; $constraints = $this->pc->validationConstraints(); $this->assertFalse(empty($constraints)); $this->assertTrue(array_key_exists("app", $constraints)); $this->assertTrue(array_key_exists("user", $constraints)); $constraint = $this->pc->validationConstraints("app"); $this->assertFalse(empty($constraint)); $this->assertTrue(array_key_exists("app", $constraint)); $this->assertEquals(1, sizeof($constraint)); $this->pc->addValidationConstraint($kittenType, "paws", Constraint::required()); $constraint = $this->pc->validationConstraints($kittenType); $this->assertTrue(array_key_exists("paws", $constraint[$kittenType])); $ct = new ParaObject("felix"); $ct->setType($kittenType); $ct2 = null; try { // validation fails $ct2 = $this->pc->create($ct); } catch (\Exception $e) { } $this->assertNull($ct2); $ct->paws = "4"; $this->assertNotNull($this->pc->create($ct)); $this->pc->removeValidationConstraint($kittenType, "paws", "required"); $constraint = $this->pc->validationConstraints($kittenType); $this->assertTrue(empty($constraint)); $this->assertFalse(array_key_exists($kittenType, $constraint)); }