Skip to content

Commit ddb4b32

Browse files
committed
test afterconstruct event
1 parent 44d6fcf commit ddb4b32

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/DocumentEventTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ class DocumentWithAfterConstructEvent extends Document
66
{
77
public $status;
88

9+
public $param = 42;
10+
911
public function beforeConstruct()
1012
{
1113
$that = $this;
12-
$this->onAfterConstruct(function() use($that) {
13-
$that->status = true;
14+
15+
$this->onAfterConstruct(function(Event $event) use($that) {
16+
17+
$that->status = $event->getTarget()->param;
1418
});
1519
}
1620
}
@@ -55,7 +59,7 @@ public function testOnAfterConstruct()
5559

5660
$document = $collectionMock->createDocument();
5761

58-
$this->assertEquals(true, $document->status);
62+
$this->assertEquals(42, $document->status);
5963

6064
}
6165

@@ -417,4 +421,4 @@ public function testCancelOperation_BeforeValidate()
417421
})
418422
->validate();
419423
}
420-
}
424+
}

0 commit comments

Comments
 (0)