Created
June 23, 2016 20:26
-
-
Save mergeweb/50fca1bcbde9843c2deaddb923f56177 to your computer and use it in GitHub Desktop.
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
<?php | |
public function testImplementedEvents() | |
{ | |
$eventsToTest = [ | |
'Table.Listings.bid_approved' => 'logUserApprovedBid', | |
'Table.Listings.bids_rejected' => 'logUserRejectBids', | |
'Table.Listings.bids_reset' => 'logUserResetBids', | |
'Table.Listings.publish' => 'logUserPublishListing', | |
'Table.Bids.bid' => 'logUserBid', | |
'Controller.Users.login' => 'logUserLogin' | |
]; | |
$user = $this->UserLogs->Users->newEntity([ | |
'username' => 'barkley' | |
]); | |
foreach($eventsToTest as $event => $function) { | |
$listener = $this->getMockBuilder('App\Listener\UserLogListener') | |
->setMethods($this->_getMethodsExcluding(['implementedEvents'])) | |
->getMock(); | |
$listener->expects($this->once()) | |
->method($function); | |
$this->UserLogs->Users->eventManager()->on($listener); | |
$event = new Event($event); | |
$this->UserLogs->Users->eventManager()->dispatch($event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment