public function testGameNotificationsComingUpCorrectly() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $this->assertEquals(0, GameNotification::getCount()); $this->assertEquals(0, count(GameNotification::getAllByUser($super))); $content = $this->runControllerWithNoExceptionsAndGetContent('gamification/default/leaderboard'); $this->assertNotContains('ModalGameNotification0', $content); //Level up notification $gameNotification = new GameNotification(); $gameNotification->user = $super; $gameNotification->setLevelChangeByNextLevelValue(2, 5); $saved = $gameNotification->save(); $this->assertTrue($saved); $this->assertEquals(1, GameNotification::getCount()); $this->assertEquals(1, count(GameNotification::getAllByUser($super))); $content = $this->runControllerWithNoExceptionsAndGetContent('gamification/default/leaderboard'); $this->assertContains('ModalGameNotification0', $content); $this->assertNotContains('ModalGameNotification1', $content); $this->assertEquals(0, GameNotification::getCount()); $this->assertEquals(0, count(GameNotification::getAllByUser($super))); Yii::app()->clientScript->reset(); $content = $this->runControllerWithNoExceptionsAndGetContent('gamification/default/leaderboard'); $this->assertNotContains('ModalGameNotification0', $content); //New badge notification $gameNotification = new GameNotification(); $gameNotification->user = $super; $gameNotification->setNewBadgeByType('LoginUser'); $saved = $gameNotification->save(); $this->assertTrue($saved); //Badge grade up notification $gameNotification = new GameNotification(); $gameNotification->user = $super; $gameNotification->setBadgeGradeChangeByTypeAndNewGrade('LoginUser', 5); $saved = $gameNotification->save(); $this->assertTrue($saved); Yii::app()->clientScript->reset(); $content = $this->runControllerWithNoExceptionsAndGetContent('gamification/default/leaderboard'); $this->assertContains('ModalGameNotification0', $content); $this->assertContains('ModalGameNotification1', $content); }