-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
0 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -599,38 +599,4 @@ public function testJoinHasOneHasMany() | |
['id' => 41, 'contact_id' => 10, 'address' => '[email protected]'], | ||
], $m_u->ref('Email')->export()); | ||
} | ||
|
||
public function testJoinOneOnOne() | ||
{ | ||
$this->setDb([ | ||
'user' => [ | ||
10 => ['id' => 10, 'name' => 'John'], | ||
20 => ['id' => 20, 'name' => 'Peter'], | ||
], 'detail' => [ | ||
100 => ['id' => 100, 'user_id' => 10, 'notes' => 'first note'], | ||
200 => ['id' => 200, 'user_id' => 20, 'notes' => 'second note'], | ||
], | ||
]); | ||
|
||
$db = new Persistence\Sql($this->db->connection); | ||
$m_user = new Model($db, 'user'); | ||
$m_user->addField('name'); | ||
$j = $m_user->join('detail', [ | ||
'master_field' => 'id', | ||
'foreign_field' => 'user_id', | ||
]); | ||
$j->addField('notes'); | ||
|
||
// try load one record | ||
$m = (clone $m_user)->tryLoad(20); | ||
$this->assertTrue($m->loaded()); | ||
$this->assertEquals(['id' => 20, 'name' => 'Peter', 'notes' => 'second note'], $m->get()); | ||
|
||
// insert new record | ||
$m = (clone $m_user)->save(['name' => 'Emily']); | ||
var_export($this->getDb()); | ||
|
||
|
||
|
||
} | ||
} |