mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW Add getJoinTable to MMTL
This commit is contained in:
parent
fe5a271634
commit
1a57c7c1d0
@ -230,4 +230,13 @@ class ManyManyThroughList extends RelationList
|
||||
$joinClass = $this->manipulator->getJoinClass();
|
||||
return Config::inst()->get($joinClass, 'db');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJoinTable()
|
||||
{
|
||||
$joinClass = $this->manipulator->getJoinClass();
|
||||
return DataObject::getSchema()->tableName($joinClass);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\ManyManyThroughList;
|
||||
use SilverStripe\ORM\Tests\ManyManyThroughListTest\PolyItem;
|
||||
use SilverStripe\ORM\Tests\ManyManyThroughListTest\PolyJoinObject;
|
||||
|
||||
class ManyManyThroughListTest extends SapphireTest
|
||||
{
|
||||
@ -261,4 +262,19 @@ class ManyManyThroughListTest extends SapphireTest
|
||||
['Title' => 'New Item'],
|
||||
], $objB2->Items());
|
||||
}
|
||||
|
||||
public function testGetJoinTable()
|
||||
{
|
||||
$joinTable = DataObject::getSchema()->tableName(PolyJoinObject::class);
|
||||
/** @var ManyManyThroughListTest\PolyObjectA $objA1 */
|
||||
$objA1 = $this->objFromFixture(ManyManyThroughListTest\PolyObjectA::class, 'obja1');
|
||||
/** @var ManyManyThroughListTest\PolyObjectB $objB1 */
|
||||
$objB1 = $this->objFromFixture(ManyManyThroughListTest\PolyObjectB::class, 'objb1');
|
||||
/** @var ManyManyThroughListTest\PolyObjectB $objB2 */
|
||||
$objB2 = $this->objFromFixture(ManyManyThroughListTest\PolyObjectB::class, 'objb2');
|
||||
|
||||
$this->assertEquals($joinTable, $objA1->Items()->getJoinTable());
|
||||
$this->assertEquals($joinTable, $objB1->Items()->getJoinTable());
|
||||
$this->assertEquals($joinTable, $objB2->Items()->getJoinTable());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user