Skip to content

Commit

Permalink
test afterconstruct event
Browse files Browse the repository at this point in the history
  • Loading branch information
sokil committed Nov 2, 2017
1 parent 44d6fcf commit ddb4b32
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/DocumentEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ class DocumentWithAfterConstructEvent extends Document
{
public $status;

public $param = 42;

public function beforeConstruct()
{
$that = $this;
$this->onAfterConstruct(function() use($that) {
$that->status = true;

$this->onAfterConstruct(function(Event $event) use($that) {

$that->status = $event->getTarget()->param;
});
}
}
Expand Down Expand Up @@ -55,7 +59,7 @@ public function testOnAfterConstruct()

$document = $collectionMock->createDocument();

$this->assertEquals(true, $document->status);
$this->assertEquals(42, $document->status);

}

Expand Down Expand Up @@ -417,4 +421,4 @@ public function testCancelOperation_BeforeValidate()
})
->validate();
}
}
}

0 comments on commit ddb4b32

Please sign in to comment.