atk4\data\tests\JoinSQLTest::testJoinSaving1 PHP Method

testJoinSaving1() public method

public testJoinSaving1 ( )
    public function testJoinSaving1()
    {
        $a = ['user' => ['_' => ['id' => 1, 'name' => 'John', 'contact_id' => 1]], 'contact' => ['_' => ['id' => 1, 'contact_phone' => '+123']]];
        $db = new Persistence_SQL($this->db->connection);
        $m_u = new Model($db, 'user');
        $this->setDB($a);
        $m_u->addField('contact_id');
        $m_u->addField('name');
        $j = $m_u->join('contact');
        $j->addField('contact_phone');
        $m_u['name'] = 'John';
        $m_u['contact_phone'] = '+123';
        $m_u->save();
        $m_u->unload();
        $this->assertEquals(['user' => [1 => ['id' => 1, 'name' => 'John', 'contact_id' => 1]], 'contact' => [1 => ['id' => 1, 'contact_phone' => '+123']]], $this->getDB('user,contact'));
        $m_u['name'] = 'Joe';
        $m_u['contact_phone'] = '+321';
        $m_u->save();
        $this->assertEquals(['user' => [1 => ['id' => 1, 'name' => 'John', 'contact_id' => 1], 2 => ['id' => 2, 'name' => 'Joe', 'contact_id' => 2]], 'contact' => [1 => ['id' => 1, 'contact_phone' => '+123'], 2 => ['id' => 2, 'contact_phone' => '+321']]], $this->getDB('user,contact'));
    }