/**
     * Test if default file format works
     *
     * @test
     * @return void
     */
    public function viewHelperReturnsCorrectJs()
    {
        $newsRepository = $this->objectManager->get('Tx_News_Domain_Repository_NewsRepository');
        $newUid = $this->testingFramework->createRecord('tx_news_domain_model_news', array('pid' => 98, 'title' => 'fobar'));
        $newsItem = $newsRepository->findByUid($newUid);
        $language = 'en';
        $viewHelper = new Tx_News_ViewHelpers_Social_DisqusViewHelper();
        $settingsService = $this->getAccessibleMock('Tx_News_Service_SettingsService');
        $settingsService->expects($this->any())->method('getSettings')->will($this->returnValue(array('disqusLang' => $language)));
        $viewHelper->injectSettingsService($settingsService);
        $actualResult = $viewHelper->render($newsItem, 'abcdef', 'http://typo3.org/dummy/fobar.html');
        $expectedCode = '<script type="text/javascript">
					var disqus_shortname = ' . t3lib_div::quoteJSvalue('abcdef', TRUE) . ';
					var disqus_identifier = ' . t3lib_div::quoteJSvalue('news_' . $newUid, TRUE) . ';
					var disqus_url = ' . t3lib_div::quoteJSvalue('http://typo3.org/dummy/fobar.html') . ';
					var disqus_title = ' . t3lib_div::quoteJSvalue('fobar', TRUE) . ';
					var disqus_config = function () {
						this.language = ' . t3lib_div::quoteJSvalue($language) . ';
					};

					(function() {
						var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
						dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
						(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
					})();
				</script>';
        $this->assertEquals($expectedCode, $actualResult);
    }
 /**
  * Add is_dummy_record record and create dummy record
  *
  * @return void
  */
 private function prepareTables()
 {
     $sql = 'ALTER TABLE %s ADD is_dummy_record tinyint(1) unsigned DEFAULT \'0\' NOT NULL';
     foreach ($this->tables as $table) {
         $_sql = sprintf($sql, $table);
         $this->database->sql_query($_sql);
     }
     $values = array('title' => uniqid('title'), 'is_dummy_record' => 1);
     $this->categoryUid = $this->testingFramework->createRecord('sys_category', $values);
 }
Exemplo n.º 3
0
 /**
  * Test if no CSS link is returned if no banners given
  *
  * @test
  * @return void
  */
 public function getAdditionalCssLinkReturnsLinkTest()
 {
     $pid = 115;
     $this->testingFramework->createRecord('tx_sfbanners_domain_model_banner', array('pid' => $pid, 'margin_left' => 10, 'margin_right' => 10, 'sorting' => 1));
     /* Get banner from Repository */
     $this->demand->setStartingPoint($pid);
     $banners = $this->bannerRepository->findDemanded($this->demand);
     $result = $this->bannerService->getAdditionalCssLink($banners);
     $this->assertContains('<link rel="stylesheet" type="text/css" href=', $result);
     $this->assertContains('typo3temp/stylesheet_', $result);
     $this->assertContains('.css', $result);
     $this->assertContains('media="all" />', $result);
 }
Exemplo n.º 4
0
 /**
  * Test if records are not returned, if max clicks and/or max impressions reached
  *
  * @test
  * @return void
  */
 public function findRecordsWithMaxImpressionsAndMaxClicksTest()
 {
     /** @var \DERHANSEN\SfBanners\Domain\Model\BannerDemand $demand  */
     $demand = $this->objectManager->get('DERHANSEN\\SfBanners\\Domain\\Model\\BannerDemand');
     $pid = 101;
     /* Create some banners */
     $this->testingFramework->createRecord('tx_sfbanners_domain_model_banner', array('pid' => $pid, 'impressions_max' => 0, 'impressions' => 10, 'clicks' => 0, 'clicks_max' => 10));
     $this->testingFramework->createRecord('tx_sfbanners_domain_model_banner', array('pid' => $pid, 'impressions_max' => 10, 'impressions' => 10, 'clicks' => 0, 'clicks_max' => 10));
     $this->testingFramework->createRecord('tx_sfbanners_domain_model_banner', array('pid' => $pid, 'impressions_max' => 0, 'impressions' => 10, 'clicks' => 10, 'clicks_max' => 10));
     $this->testingFramework->createRecord('tx_sfbanners_domain_model_banner', array('pid' => $pid, 'impressions_max' => 10, 'impressions' => 10, 'clicks' => 10, 'clicks_max' => 10));
     /* Set starting point */
     $demand->setStartingPoint($pid);
     /* Verify, that 2 records are returned */
     $this->assertEquals(1, (int) $this->fixture->findDemanded($demand)->count());
 }
 /**
  * Test if startingpoint is working
  *
  * @test
  * @return void
  */
 public function findRecordsByStartingpointRestriction()
 {
     $newsRepository = $this->objectManager->get('Tx_News_Domain_Repository_NewsRepository');
     /** @var $demand Tx_News_Domain_Model_Dto_NewsDemand */
     $demand = $this->objectManager->get('Tx_News_Domain_Model_Dto_NewsDemand');
     $demand->setIsDummyRecord(1);
     $pidList = array(94, 94, 95, 96, 96, 97);
     foreach ($pidList as $pid) {
         $this->testingFramework->createRecord('tx_news_domain_model_news', array('type' => 0, 'pid' => $pid));
     }
     // simple starting point
     $demand->setStoragePage(94);
     $this->assertEquals((int) $newsRepository->findDemanded($demand)->count(), 2);
     // multiple starting points
     $demand->setStoragePage('94,95,96');
     $this->assertEquals((int) $newsRepository->findDemanded($demand)->count(), 5);
     // multiple starting points, including invalid values and commas
     $demand->setStoragePage('94 , 95 , x ,97');
     $this->assertEquals((int) $newsRepository->findDemanded($demand)->count(), 4);
 }
Exemplo n.º 6
0
 /**
  * @test
  */
 public function existsRecordWithUidUsesAdditionalNonEmptyWhereClause()
 {
     $uid = $this->testingFramework->createRecord('tx_phpunit_test', array('deleted' => 1));
     self::assertFalse(\Tx_Phpunit_Service_Database::existsRecordWithUid('tx_phpunit_test', $uid, ' AND deleted = 0'));
 }
Exemplo n.º 7
0
 /**
  * @test
  *
  * @expectedException InvalidArgumentException
  */
 public function increaseRelationCounterThrowsExceptionOnInexistentFieldName()
 {
     $uid = $this->fixture->createRecord('tx_phpunit_test');
     $this->fixture->increaseRelationCounter('tx_phpunit_test', $uid, 'inexistent_column');
 }