atk4\data\tests\JoinArrayTest::testDirection PHP Method

testDirection() public method

public testDirection ( )
    public function testDirection()
    {
        $a = ['user' => [], 'contact' => []];
        $db = new Persistence_Array($a);
        $m = new Model($db, 'user');
        $j = $m->join('contact');
        $this->assertEquals(false, $this->getProtected($j, 'reverse'));
        $this->assertEquals('contact_id', $this->getProtected($j, 'master_field'));
        $this->assertEquals('id', $this->getProtected($j, 'foreign_field'));
        $j = $m->join('contact2.test_id');
        $this->assertEquals(true, $this->getProtected($j, 'reverse'));
        $this->assertEquals('id', $this->getProtected($j, 'master_field'));
        $this->assertEquals('test_id', $this->getProtected($j, 'foreign_field'));
        $j = $m->join('contact3', 'test_id');
        $this->assertEquals(false, $this->getProtected($j, 'reverse'));
        $this->assertEquals('test_id', $this->getProtected($j, 'master_field'));
        $this->assertEquals('id', $this->getProtected($j, 'foreign_field'));
        $j = $m->join('contact3', ['test_id']);
        $this->assertEquals(false, $this->getProtected($j, 'reverse'));
        $this->assertEquals('test_id', $this->getProtected($j, 'master_field'));
        $this->assertEquals('id', $this->getProtected($j, 'foreign_field'));
        $j = $m->join('contact4.foo_id', ['test_id', 'reverse' => true]);
        $this->assertEquals(true, $this->getProtected($j, 'reverse'));
        $this->assertEquals('test_id', $this->getProtected($j, 'master_field'));
        $this->assertEquals('foo_id', $this->getProtected($j, 'foreign_field'));
    }