/** * Test account attribute that is a hasOne relation off of Opportunity */ public function testModifyingAHasOneModelRelationDoesNotCreateNewAttribute() { $opportunity = new Opportunity(false); $this->assertEquals(17, count($opportunity->getAttributes())); $validated = $opportunity->validate(); $this->assertFalse($validated); $this->assertEquals(6, count($opportunity->getErrors())); $attributeForm = AttributesFormFactory::createAttributeFormByAttributeName($opportunity, 'account'); $this->assertFalse($attributeForm->isRequired); $modelAttributesAdapterClassName = $attributeForm::getModelAttributeAdapterNameForSavingAttributeFormData(); $adapter = new $modelAttributesAdapterClassName(new Opportunity()); $attributeForm->isRequired = true; $adapter->setAttributeMetadataFromForm($attributeForm); $opportunity = new Opportunity(false); $this->assertEquals(17, count($opportunity->getAttributes())); $validated = $opportunity->validate(); $this->assertFalse($validated); $this->assertEquals(7, count($opportunity->getErrors())); }