/** * @param Table $table * * @return bool */ protected function hasCompositeNumberRangeBehavior(Table $table) { if ($table->hasBehavior(self::BEHAVIOR_NAME)) { if ($table->hasBehavior('concrete_inheritance')) { // we're a child in a concrete inheritance $parentTableName = $table->getBehavior('concrete_inheritance')->getParameter('extends'); $parentTable = $table->getDatabase()->getTable($parentTableName); if ($parentTable->hasBehavior(self::BEHAVIOR_NAME)) { //we're a child of a concrete inheritance structure, so we're going to skip this //round here because this behavior has also been attached by the parent table. return false; } } return true; } return false; }
public function testHasBehaviors() { $behavior1 = $this->getBehaviorMock('Foo'); $behavior2 = $this->getBehaviorMock('Bar'); $behavior3 = $this->getBehaviorMock('Baz'); $table = new Table(); $table->addBehavior($behavior1); $table->addBehavior($behavior2); $table->addBehavior($behavior3); $this->assertCount(3, $table->getBehaviors()); $this->assertTrue($table->hasBehavior('Foo')); $this->assertTrue($table->hasBehavior('Bar')); $this->assertTrue($table->hasBehavior('Baz')); $this->assertFalse($table->hasBehavior('Bab')); $this->assertSame($behavior1, $table->getBehavior('Foo')); $this->assertSame($behavior2, $table->getBehavior('Bar')); $this->assertSame($behavior3, $table->getBehavior('Baz')); }