function testGetTagWithoutTitleContainingDots() { $image = $this->objFromFixture('Image', 'imageWithoutTitleContainingDots'); $expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test.image.with.dots.png" alt="test.image.with.dots" />'; $actual = $image->getTag(); $this->assertEquals($expected, $actual); }
public function testChangePasswordFromLostPassword() { $admin = $this->objFromFixture('Member', 'test'); $admin->FailedLoginCount = 99; $admin->LockedOutUntil = SS_Datetime::now()->Format('Y-m-d H:i:s'); $admin->write(); $this->assertNull($admin->AutoLoginHash, 'Hash is empty before lost password'); // Request new password by email $response = $this->get('Security/lostpassword'); $response = $this->post('Security/LostPasswordForm', array('Email' => '*****@*****.**')); $this->assertEmailSent('*****@*****.**'); // Load password link from email $admin = DataObject::get_by_id('Member', $admin->ID); $this->assertNotNull($admin->AutoLoginHash, 'Hash has been written after lost password'); // We don't have access to the token - generate a new token and hash pair. $token = $admin->generateAutologinTokenAndStoreHash(); // Check. $response = $this->get('Security/changepassword/?m=' . $admin->ID . '&t=' . $token); $this->assertEquals(302, $response->getStatusCode()); $this->assertEquals(Director::baseUrl() . 'Security/changepassword', $response->getHeader('Location')); // Follow redirection to form without hash in GET parameter $response = $this->get('Security/changepassword'); $changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword'); $this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs')); // Check if we can login with the new password $goodResponse = $this->doTestLoginForm('*****@*****.**', 'changedPassword'); $this->assertEquals(302, $goodResponse->getStatusCode()); $this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs')); $admin = DataObject::get_by_id('Member', $admin->ID, false); $this->assertNull($admin->LockedOutUntil); $this->assertEquals(0, $admin->FailedLoginCount); }
function testChangePasswordFromLostPassword() { $admin = $this->objFromFixture('Member', 'test'); $this->assertNull($admin->AutoLoginHash, 'Hash is empty before lost password'); // Request new password by email $response = $this->get('Security/lostpassword'); $response = $this->submitForm('MemberLoginForm_LostPasswordForm', null, array('Email' => '*****@*****.**')); $this->assertEmailSent('*****@*****.**'); // Load password link from email $admin = DataObject::get_by_id('Member', $admin->ID); $this->assertNotNull($admin->AutoLoginHash, 'Hash has been written after lost password'); $response = $this->get('Security/changepassword/?h=' . $admin->AutoLoginHash); $this->assertEquals(302, $response->getStatusCode()); $this->assertEquals(Director::baseUrl() . 'Security/changepassword', $response->getHeader('Location')); // Follow redirection to form without hash in GET parameter $response = $this->get('Security/changepassword'); $changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword'); $this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs')); // Check if we can login with the new password $goodResponse = $this->doTestLoginForm('*****@*****.**', 'changedPassword'); $this->assertEquals(302, $goodResponse->getStatusCode()); $this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs')); }
public function testGetTagWithoutTitleContainingDots() { Config::inst()->update('Image', 'force_resample', false); $image = $this->objFromFixture('Image', 'imageWithoutTitleContainingDots'); $expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test.image.with.dots.png" alt="test.image.with.dots" />'; $actual = $image->getTag(); $this->assertEquals($expected, $actual); }
/** * Builds and returns the form action to use. * * @return string * * @author Sebastian Diel <*****@*****.**>, * Sascha Koehler <*****@*****.**> * @since 04.07.2013 */ protected function buildFormAction() { if (is_null($this->customHtmlFormAction)) { $formAction = Controller::join_links($this->getFormController($this->controller, $this->basePreferences)->Link(), $this->getSubmitAction()); } else { $formAction = Director::baseUrl() . 'customhtmlformaction/' . $this->customHtmlFormAction; } return $formAction; }
/** * Returns the base url. * * @return string * * @author Sascha Koehler <*****@*****.**> * @since 16.05.2012 */ public function BaseUrl() { return Director::baseUrl(); }
public function Link($action = null) { return Controller::join_links(Director::baseUrl(), 'dev/testsession', $action); }
/** * Returns the base URL segment that's used for inclusion of css and * javascript files via Requirements. * * @return string * * @author Sascha Koehler <*****@*****.**> * @since 16.02.2012 */ public static function getBaseURLSegment() { if (is_null(self::$baseURLSegment)) { $baseUrl = Director::baseUrl(); if ($baseUrl === '/') { $baseUrl = ''; } if (!empty($baseUrl) && substr($baseUrl, -1) != '/') { $baseUrl .= '/'; } self::$baseURLSegment = $baseUrl; } return self::$baseURLSegment; }