|
|
@@ -111,6 +111,42 @@ class AssociationTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Tests that setName() succeeds before the target table is resolved.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testSetNameBeforeTarget()
|
|
|
+ {
|
|
|
+ $this->association->setName('Bar');
|
|
|
+ $this->assertEquals('Bar', $this->association->getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Tests that setName() fails after the target table is resolved.
|
|
|
+ *
|
|
|
+ * @expectedException \InvalidArgumentException
|
|
|
+ * @expectedExceptionMessage Association name does not match target table alias.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testSetNameAfterTarger()
|
|
|
+ {
|
|
|
+ $this->association->getTarget();
|
|
|
+ $this->association->setName('Bar');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Tests that setName() succeeds if name equals target table alias.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testSetNameToTargetAlias()
|
|
|
+ {
|
|
|
+ $alias = $this->association->getTarget()->getAlias();
|
|
|
+ $this->association->setName($alias);
|
|
|
+ $this->assertEquals($alias, $this->association->getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Tests that className() returns the correct association className
|
|
|
*
|
|
|
* @return void
|