/** * 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); }
/** * 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); }
/** * @test * @return void */ public function loggedinUserFoundInDbHasEqualMd5EncryptedPassword() { $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sfregister.']['settings.']['encryptPassword'] = '******'; $this->fixture->_set('settings', $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sfregister.']['settings.']); $expected = 'myFancyPassword'; $userId = $this->testingFramework->createAndLoginFrontEndUser('', array('password' => $expected)); $userMock = $this->getMock('Evoweb\\SfRegister\\Domain\\Model\\FrontendUser'); $userMock->expects($this->once())->method('getPassword')->will($this->returnValue(md5($expected))); $repositoryMock = $this->getMock('Evoweb\\SfRegister\\Domain\\Repository\\FrontendUserRepository', array(), array(), '', FALSE); $repositoryMock->expects($this->once())->method('findByUid')->with($userId)->will($this->returnValue($userMock)); $this->fixture->injectUserRepository($repositoryMock); $this->assertTrue($this->fixture->isValid($expected)); }
/** * 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 * @return void */ public function saveActionFetchUserObjectIfLoggedInSetsThePasswordAndCallsUpdateOnUserrepository() { // we dont want to test the encryption here if (isset($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sfregister.']['settings.']['encryptPassword'])) { unset($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sfregister.']['settings.']['encryptPassword']); } $expected = 'myPassword'; $userId = $this->testingFramework->createAndLoginFrontEndUser('', array('password' => $expected)); // we need to clone the create object else the isClone param // is not set and the both object wont match $userMock = clone new \Evoweb\SfRegister\Domain\Model\FrontendUser(); $repositoryMock = $this->getMock('Evoweb\\SfRegister\\Domain\\Repository\\FrontendUserRepository', array(), array(), '', FALSE); $repositoryMock->expects($this->once())->method('findByUid')->with($userId)->will($this->returnValue($userMock)); $userMock->setPassword($expected); $repositoryMock->expects($this->once())->method('update')->with($userMock); $this->fixture->injectUserRepository($repositoryMock); /** @var \Evoweb\SfRegister\Domain\Model\Password|\PHPUnit_Framework_MockObject_MockObject $passwordMock */ $passwordMock = $this->getMock('Evoweb\\SfRegister\\Domain\\Model\\Password'); $passwordMock->expects($this->once())->method('getPassword')->will($this->returnValue($expected)); $this->fixture->saveAction($passwordMock); }
/** * Purges the cached hooks. * * @return void */ public function purgeHooks() { self::$hooks = array(); self::$hooksHaveBeenRetrieved = FALSE; }
/** * @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')); }
/** * Tear down and remove records * * @return void */ public function tearDown() { $this->testingFramework->cleanUp(); unset($this->testingFramework); }
/** * @test */ public function createBackEndUserGroupForTitleGivenStoresTitleInGroupRecord() { $this->fixture->createBackEndUserGroup(array('title' => 'foo group')); $this->assertTrue($this->fixture->existsRecord('be_groups', 'title = "foo group"')); }
/** * @test * @return void */ public function findByMailhashReturnsUserThatShouldGetActivated() { $expected = 'testHash'; $this->testingFramework->createAndLoginFrontEndUser('', array('tx_extbase_type' => 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUser', 'mailhash' => $expected)); $this->assertInstanceOf('Evoweb\\SfRegister\\Domain\\Model\\FrontendUser', $this->fixture->findByMailhash($expected)); }