/** * @covers ::getUserNotifications */ public function testGetUserNotificationsUnreadOnly() { $mockdb = new \TMT\MockDB(); $mockdb->expectPrepare("SELECT notifications.*, userNotifications.netId, userNotifications.read FROM notifications JOIN userNotifications\n\t\t\tON notifications.guid=userNotifications.notificationGuid WHERE userNotifications.netId=:netId AND userNotifications.deleted=0 AND userNotifications.read=0"); $mockdb->expectExecute(array(':netId' => "netId")); $mockdb->setReturnData(array((object) array("guid" => "guid1", "netId" => "netId", "timestamp" => "2000-01-01 00:00:00", "message" => "message", "area" => "areaguid", "type" => "type1", "read" => "0"), (object) array("guid" => "guid2", "netId" => "netId", "timestamp" => "2000-01-01 11:11:11", "message" => "stuff", "area" => "area2", "type" => "type2", "read" => "0"))); $expected = array(new \TMT\model\UserNotification(array("guid" => "guid1", "netId" => "netId", "timestamp" => "2000-01-01 00:00:00", "message" => "message", "area" => "areaguid", "type" => "type1", "read" => "0")), new \TMT\model\UserNotification(array("guid" => "guid2", "netId" => "netId", "timestamp" => "2000-01-01 11:11:11", "message" => "stuff", "area" => "area2", "type" => "type2", "read" => "0"))); $accessor = new UserNotification($mockdb); $actual = $accessor->getUserNotifications("netId", false); $this->assertEquals($expected, $actual); $mockdb->verify(); }