/** * test extracting extra HasMany * * @return void */ public function testFilterHasManyAssociationsAliasesExtra() { $table = TableRegistry::get('Articles', ['className' => '\\Bake\\Test\\App\\Model\\Table\\ArticlesTable']); $table->hasMany('ExtraArticles', ['className' => 'Articles']); $result = $this->associationFilter->filterHasManyAssociationsAliases($table, ['ExtraArticles', 'ArticlesTags', 'AnotherHasMany']); $expected = ['ExtraArticles', 'AnotherHasMany']; $this->assertSame($expected, $result, 'hasMany should filter results based on belongsToMany existing aliases'); $table->associations()->remove('ExtraArticles'); }
/** * To be mocked elsewhere... * * @param \Cake\ORM\Table $table Table * @param array $aliases array of aliases */ protected function _filterHasManyAssociationsAliases($table, $aliases) { if (is_null($this->_associationFilter)) { $this->_associationFilter = new AssociationFilter(); } return $this->_associationFilter->filterHasManyAssociationsAliases($table, $aliases); }