Skip to content

Commit e02cff1

Browse files
authored
Merge pull request #199 from robindirksen1/patch-2
Error with dirty attributes (Fix #198)
2 parents 8037a02 + 7ff480e commit e02cff1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Picqer/Financials/Moneybird/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function getDirtyValues()
214214
*/
215215
public function isAttributeDirty($attributeName)
216216
{
217-
if (in_array($attributeName, $this->attribute_changes)) {
217+
if (array_key_exists($attributeName, $this->attribute_changes)) {
218218
return true;
219219
}
220220

tests/PicqerTest/Financials/Moneybird/ModelTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public function testRegisterAttributesAsDirty()
114114
$this->assertEquals('id', $invoice->getDirty()[0]);
115115
$this->assertEquals('invoice_date', $invoice->getDirty()[1]);
116116
$this->assertEquals(2, count($invoice->getDirty()));
117+
$this->assertTrue($invoice->isAttributeDirty('id'));
118+
$this->assertTrue($invoice->isAttributeDirty('invoice_date'));
119+
$this->assertFalse($invoice->isAttributeDirty('unknown_key'));
117120

118121
//check if the getDirtyValues from is null (new object)
119122
$this->assertEquals(null, $invoice->getDirtyValues()['invoice_date']['from']);

0 commit comments

Comments
 (0)