Commit 9d3af517 authored by Karamel's avatar Karamel
Browse files

Fix DoctrineMainModel getLoadKey, that may not have produced bugs yet

parent 25ebca29
...@@ -116,7 +116,7 @@ abstract class DoctrineMainModel extends DoctrineModel ...@@ -116,7 +116,7 @@ abstract class DoctrineMainModel extends DoctrineModel
} else { } else {
$key = []; $key = [];
foreach ($refField as $fieldName) { foreach ($refField as $fieldName) {
if (!array_key_exists($fieldName, $ref)) { if (!array_key_exists($fieldName, $struct)) {
return null; return null;
} }
$key[$fieldName] = $struct[$fieldName]; $key[$fieldName] = $struct[$fieldName];
......
...@@ -317,6 +317,18 @@ class CashSessionTest extends TestCase ...@@ -317,6 +317,18 @@ class CashSessionTest extends TestCase
$session->setCS(5); $session->setCS(5);
} }
public function testGetLoadKey() {
$valid = ['cashRegister' => 1, 'sequence' => '2'];
$validLoad = CashSession::getLoadKey($valid);
$this->assertTrue(array_key_exists('cashRegister', $validLoad));
$this->assertTrue(array_key_exists('sequence', $validLoad));
$this->assertEquals(1, $validLoad['cashRegister']);
$this->assertEquals(2, $validLoad['sequence']);
$invalid = ['notRef' => 'ref'];
$invalidLoad = CashSession::getLoadKey($invalid);
$this->assertNull($invalidLoad);
}
private function initEmptySession() { private function initEmptySession() {
$session = new CashSession(); $session = new CashSession();
$session->setCashRegister($this->cashRegister); $session->setCashRegister($this->cashRegister);
......
...@@ -156,6 +156,16 @@ class CategoryTest extends TestCase ...@@ -156,6 +156,16 @@ class CategoryTest extends TestCase
$this->assertEquals($cat->getDispOrder(), $parent->getDispOrder()); $this->assertEquals($cat->getDispOrder(), $parent->getDispOrder());
} }
public function testGetLoadKey() {
$valid = ['reference' => 'ref'];
$validLoad = Category::getLoadKey($valid);
$this->assertTrue(array_key_exists('reference', $validLoad));
$this->assertEquals('ref', $validLoad['reference']);
$invalid = ['notRef' => 'ref'];
$invalidLoad = Category::getLoadKey($invalid);
$this->assertNull($invalidLoad);
}
public function testEqualsSimple() { public function testEqualsSimple() {
$cat = new Category(); $cat = new Category();
$cat->setReference('Ref'); $cat->setReference('Ref');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment