public function testGetStatistics() { $newsletter = $this->newsletterRepository->findByUid(30); $stats = $this->newsletterRepository->getStatistics($newsletter); $expected = array(array('time' => 1423729050, 'emailNotSentCount' => 2, 'emailSentCount' => 0, 'emailOpenedCount' => 0, 'emailBouncedCount' => 0, 'emailCount' => 2, 'linkOpenedCount' => 0, 'linkCount' => 2, 'emailNotSentPercentage' => 100, 'emailSentPercentage' => 0, 'emailOpenedPercentage' => 0, 'emailBouncedPercentage' => 0, 'linkOpenedPercentage' => 0), array('time' => 1423729053, 'emailNotSentCount' => 1, 'emailSentCount' => 1, 'emailOpenedCount' => 0, 'emailBouncedCount' => 0, 'emailCount' => 2, 'linkOpenedCount' => 0, 'linkCount' => 2, 'emailNotSentPercentage' => 50.0, 'emailSentPercentage' => 50.0, 'emailOpenedPercentage' => 0, 'emailBouncedPercentage' => 0, 'linkOpenedPercentage' => 0), array('time' => 1423729055, 'emailNotSentCount' => 1, 'emailSentCount' => 0, 'emailOpenedCount' => 1, 'emailBouncedCount' => 0, 'emailCount' => 2, 'linkOpenedCount' => 0, 'linkCount' => 2, 'emailNotSentPercentage' => 50.0, 'emailSentPercentage' => 0, 'emailOpenedPercentage' => 50.0, 'emailBouncedPercentage' => 0, 'linkOpenedPercentage' => 0), array('time' => 1423729056, 'emailNotSentCount' => 1, 'emailSentCount' => 0, 'emailOpenedCount' => 1, 'emailBouncedCount' => 0, 'emailCount' => 2, 'linkOpenedCount' => 1, 'linkCount' => 2, 'emailNotSentPercentage' => 50.0, 'emailSentPercentage' => 0, 'emailOpenedPercentage' => 50.0, 'emailBouncedPercentage' => 0, 'linkOpenedPercentage' => 25.0)); $this->assertSame($expected, $stats); }
/** * Returns the newsletter with included statistics to be used for timeline chart * @param int $uidNewsletter */ public function statisticsAction($uidNewsletter) { $newsletter = $this->newsletterRepository->findByUid($uidNewsletter); $this->view->setVariablesToRender(['data', 'success', 'total']); $conf = self::resolveJsonViewConfiguration(); $conf['_only'][] = 'statistics'; $conf['_descend'][] = 'statistics'; $this->view->setConfiguration(['data' => $conf]); $this->view->assign('total', 1); $this->view->assign('success', true); $this->view->assign('data', $newsletter); }