public function setUp()
 {
     parent::setUp();
     Config::nest();
     Config::inst()->update('HtmlEditorField_Toolbar', 'fileurl_scheme_whitelist', array('http'));
     Config::inst()->update('HtmlEditorField_Toolbar', 'fileurl_domain_whitelist', array('example.com'));
 }
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     Injector::nest();
     $this->securityWasEnabled = SecurityToken::is_enabled();
     // Check dependencies
     if (!class_exists('Phockito')) {
         $this->skipTest = true;
         return $this->markTestSkipped("These tests need the Phockito module installed to run");
     }
     // Reset config
     Config::inst()->update('SpellController', 'required_permission', 'CMS_ACCESS_CMSMain');
     Config::inst()->remove('SpellController', 'locales');
     Config::inst()->update('SpellController', 'locales', array('en_US', 'en_NZ', 'fr_FR'));
     Config::inst()->update('SpellController', 'enable_security_token', true);
     SecurityToken::enable();
     // Setup mock for testing provider
     $spellChecker = Phockito::mock('SpellProvider');
     Phockito::when($spellChecker)->checkWords('en_NZ', array('collor', 'colour', 'color', 'onee', 'correct'))->return(array('collor', 'color', 'onee'));
     Phockito::when($spellChecker)->checkWords('en_US', array('collor', 'colour', 'color', 'onee', 'correct'))->return(array('collor', 'colour', 'onee'));
     Phockito::when($spellChecker)->getSuggestions('en_NZ', 'collor')->return(array('collar', 'colour'));
     Phockito::when($spellChecker)->getSuggestions('en_US', 'collor')->return(array('collar', 'color'));
     Injector::inst()->registerService($spellChecker, 'SpellProvider');
 }
Esempio n. 3
0
 public function testPermissionFailureSetsCorrectFormMessages()
 {
     Config::nest();
     // Controller that doesn't attempt redirections
     $controller = new SecurityTest_NullController();
     $controller->response = new SS_HTTPResponse();
     Security::permissionFailure($controller, array('default' => 'Oops, not allowed'));
     $this->assertEquals('Oops, not allowed', Session::get('Security.Message.message'));
     // Test that config values are used correctly
     Config::inst()->update('Security', 'default_message_set', 'stringvalue');
     Security::permissionFailure($controller);
     $this->assertEquals('stringvalue', Session::get('Security.Message.message'), 'Default permission failure message value was not present');
     Config::inst()->remove('Security', 'default_message_set');
     Config::inst()->update('Security', 'default_message_set', array('default' => 'arrayvalue'));
     Security::permissionFailure($controller);
     $this->assertEquals('arrayvalue', Session::get('Security.Message.message'), 'Default permission failure message value was not present');
     // Test that non-default messages work.
     // NOTE: we inspect the response body here as the session message has already
     // been fetched and output as part of it, so has been removed from the session
     $this->logInWithPermission('EDITOR');
     Config::inst()->update('Security', 'default_message_set', array('default' => 'default', 'alreadyLoggedIn' => 'You are already logged in!'));
     Security::permissionFailure($controller);
     $this->assertContains('You are already logged in!', $controller->response->getBody(), 'Custom permission failure message was ignored');
     Security::permissionFailure($controller, array('default' => 'default', 'alreadyLoggedIn' => 'One-off failure message'));
     $this->assertContains('One-off failure message', $controller->response->getBody(), "Message set passed to Security::permissionFailure() didn't override Config values");
     Config::unnest();
 }
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     // Two restarts are allowed per job
     Config::inst()->update('QueuedJobService', 'stall_threshold', 2);
 }
 public function setUp()
 {
     parent::setUp();
     // Fixtures assume Email is the field used to identify the log in identity
     Config::nest();
     Member::config()->unique_identifier_field = 'Email';
     Member::config()->lock_out_after_incorrect_logins = 10;
 }
 public function setUp()
 {
     Config::nest();
     parent::setUp();
     Config::inst()->update('Email', 'admin_email', '*****@*****.**');
     Config::inst()->update('SuspendSpammerEmail', 'email_to', '*****@*****.**');
     Config::inst()->update('SuspendSpammerEmail', 'enable_email', true);
 }
 /**
  * Set up the test
  */
 public function setUp()
 {
     Config::inst()->update('DataObject', 'validation_enabled', false);
     Config::nest();
     parent::setUp();
     $this->page = $this->objFromFixture('SummitVideoApp', 'App');
     $this->page->publish("Stage", "Live");
 }
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     Config::inst()->update('Email', 'admin_email', '*****@*****.**');
     $this->oldhost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
     $_SERVER['HTTP_HOST'] = 'www.mysite.com';
 }
 function getCustomerNote()
 {
     Config::nest();
     Config::inst()->update('SSViewer', 'theme_enabled', true);
     $html = $this->renderWith("LogDispatchPhysicalOrderCustomerNote");
     Config::unnest();
     return $html;
 }
 public function setUpOnce()
 {
     Config::nest();
     VersionableExtensionsTest_DataObject::add_extension('Versioned');
     VersionableExtensionsTest_DataObject::add_extension('VersionableExtensionsTest_Extension');
     $cfg = Config::inst();
     $cfg->update('VersionableExtensionsTest_DataObject', 'versionableExtensions', array('VersionableExtensionsTest_Extension' => array('test1', 'test2', 'test3')));
     parent::setUpOnce();
 }
Esempio n. 11
0
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     // Set good default values
     Config::inst()->update('CommentsExtension', 'comments', array('enabled' => true, 'enabled_cms' => false, 'require_login' => false, 'require_login_cms' => false, 'required_permission' => false, 'require_moderation_nonmembers' => false, 'require_moderation' => false, 'require_moderation_cms' => false, 'frontend_moderation' => false, 'frontend_spam' => false));
     // Configure this dataobject
     Config::inst()->update('CommentableItem', 'comments', array('enabled_cms' => true));
 }
 function testCustomGetVar()
 {
     Config::nest();
     Config::inst()->update('MultiForm', 'get_var', 'SuperSessionID');
     $form = $this->controller->Form();
     $this->assertContains('SuperSessionID', $form::$ignored_fields, "GET var wasn't added to ignored fields");
     $this->assertContains('SuperSessionID', $form->FormAction(), "Form action doesn't contain correct session \n\t\t\tID parameter");
     $this->assertContains('SuperSessionID', $form->getCurrentStep()->Link(), "Form step doesn't contain correct \n\t\t\tsession ID parameter");
     Config::unnest();
 }
 /**
  * Render the object using SSViewer
  * @return string
  */
 public function forPDF($variables = array())
 {
     Config::nest();
     Config::inst()->update('Director', 'alternate_base_url', static::get_render_host());
     $file = $this->owner->getPDFTemplate();
     $viewer = new SSViewer($file);
     $output = $viewer->process($this->owner, $variables);
     Config::unnest();
     return $output;
 }
 public function setUp()
 {
     parent::setUp();
     // Fixtures assume Email is the field used to identify the log in identity
     Config::nest();
     Member::config()->unique_identifier_field = 'Email';
     Security::$force_database_is_ready = true;
     // Prevents Member test subclasses breaking ready test
     Member::config()->lock_out_after_incorrect_logins = 10;
 }
 public function testTruncatesByMaxLength()
 {
     Config::nest();
     Config::inst()->update('FileTextCache_Database', 'max_content_length', 5);
     $cache = new FileTextCache_Database();
     $file = $this->getMock('File', array('write'));
     $content = '0123456789';
     $cache->save($file, $content);
     $this->assertEquals($cache->load($file), '01234');
     Config::unnest();
 }
Esempio n. 16
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     SS_Datetime::set_mock_now('2013-10-10 20:00:00');
     /**
      * @var Blog $blog
      */
     $blog = $this->objFromFixture('Blog', 'FirstBlog');
     $blog->publish('Stage', 'Live');
 }
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     // explicitly use dev/docs. Custom paths should be tested separately
     Config::inst()->update('DocumentationViewer', 'link_base', 'dev/docs');
     // disable automatic module registration so modules don't interfere.
     Config::inst()->update('DocumentationManifest', 'automatic_registration', false);
     Config::inst()->remove('DocumentationManifest', 'register_entities');
     Config::inst()->update('DocumentationManifest', 'register_entities', array(array('Path' => DOCSVIEWER_PATH . "/tests/docs/", 'Title' => 'Doc Test', 'Key' => 'testdocs', 'Version' => '2.3'), array('Path' => DOCSVIEWER_PATH . "/tests/docs-v2.4/", 'Title' => 'Doc Test', 'Version' => '2.4', 'Key' => 'testdocs', 'Stable' => true), array('Path' => DOCSVIEWER_PATH . "/tests/docs-v3.0/", 'Title' => 'Doc Test', 'Key' => 'testdocs', 'Version' => '3.0'), array('Path' => DOCSVIEWER_PATH . "/tests/docs-manifest/", 'Title' => 'Manifest', 'Key' => 'manifest')));
     $this->manifest = new DocumentationManifest(true);
 }
 public function setUp()
 {
     parent::setUp();
     $this->entity = new DocumentationEntity('doctest');
     $this->entity->setPath(DOCSVIEWER_PATH . '/tests/docs/en/');
     $this->entity->setVersion('2.4');
     $this->entity->setLanguage('en');
     Config::nest();
     // explicitly use dev/docs. Custom paths should be tested separately
     Config::inst()->update('DocumentationViewer', 'link_base', 'dev/docs/');
     $manifest = new DocumentationManifest(true);
 }
 public function setUp()
 {
     // Ensure that Fluent doesn't interfere with scaffolding records from FluentTest.yml
     Config::nest();
     $this->setDefaultConfig();
     FluentExtension::set_enable_write_augmentation(false);
     parent::setUp();
     FluentExtension::set_enable_write_augmentation(true);
     // Reset fluent locale and domain mode
     Config::inst()->update('Fluent', 'force_domain', false);
     Fluent::set_persist_locale('fr_CA');
 }
 public function setUp()
 {
     parent::setUp();
     // create 2 pages
     for ($i = 0; $i < 2; ++$i) {
         $page = new Page(array('Title' => "Page {$i}"));
         $page->write();
         $page->publish('Stage', 'Live');
     }
     // reset configuration for the test.
     Config::nest();
     Config::inst()->update('Foo', 'bar', 'Hello!');
 }
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     // explicitly use dev/docs. Custom paths should be tested separately
     Config::inst()->update('DocumentationViewer', 'link_base', 'dev/docs');
     // disable automatic module registration so modules don't interfere.
     Config::inst()->update('DocumentationManifest', 'automatic_registration', false);
     Config::inst()->remove('DocumentationManifest', 'register_entities');
     Config::inst()->update('DocumentationSearch', 'enabled', true);
     Config::inst()->update('DocumentationManifest', 'register_entities', array(array('Path' => DOCSVIEWER_PATH . "/tests/docs-search/", 'Title' => 'Docs Search Test')));
     $this->manifest = new DocumentationManifest(true);
 }
 function setUp()
 {
     parent::setUp();
     if (self::$index === null) {
         self::$index = singleton(get_class($this) . '_Index');
     } else {
         self::$index->reset();
     }
     SearchUpdater::bind_manipulation_capture();
     Config::nest();
     Config::inst()->update('Injector', 'SearchUpdateProcessor', array('class' => 'SearchUpdateImmediateProcessor'));
     FullTextSearch::force_index_list(self::$index);
     SearchUpdater::clear_dirty_indexes();
 }
 public function testFieldPosition()
 {
     Config::nest();
     Config::inst()->update('MetaTitleExtension', 'InsertBefore', 'MetaDescription');
     $testObject = new MetaTitleExtensionTest_DataObject();
     $fields = $testObject->getCMSFields();
     $descriptionPosition = $fields->fieldPosition('MetaDescription');
     $this->assertEquals($descriptionPosition - 1, $fields->fieldPosition('MetaTitle'));
     Config::inst()->update('MetaTitleExtension', 'InsertBefore', 'URLSegment');
     $fields = $testObject->getCMSFields();
     $urlSegmentPosition = $fields->fieldPosition('URLSegment');
     $this->assertEquals($urlSegmentPosition - 1, $fields->fieldPosition('MetaTitle'));
     Config::unnest();
 }
 public function setUp()
 {
     parent::setUp();
     $cache = SS_Cache::factory('VersionFeed_Controller');
     $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     $this->userIP = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : null;
     Config::nest();
     // Disable caching and locking by default
     Config::inst()->update('VersionFeed\\Filters\\CachedContentFilter', 'cache_enabled', false);
     Config::inst()->update('VersionFeed\\Filters\\RateLimitFilter', 'lock_timeout', 0);
     Config::inst()->update('VersionFeed\\Filters\\RateLimitFilter', 'lock_bypage', false);
     Config::inst()->update('VersionFeed\\Filters\\RateLimitFilter', 'lock_byuserip', false);
     Config::inst()->update('VersionFeed\\Filters\\RateLimitFilter', 'lock_cooldown', false);
 }
 public function setUp()
 {
     parent::setUp();
     Config::nest();
     HybridSessionAbstractTest_TestCookieBackend::$override_headers_sent = false;
     Config::inst()->update('HybridSessionStore_Cookie', 'key', uniqid());
     Injector::nest();
     Injector::inst()->registerService(new HybridSessionAbstractTest_TestCookieBackend(), 'HybridSessionStore_Cookie');
     SS_Datetime::set_mock_now('2010-03-15 12:00:00');
     if (get_class() === get_class($this)) {
         $this->markTestSkipped("Skipping abstract test");
         $this->skipTest = true;
     }
 }
 function getTableTitle()
 {
     $tableTitle = _t("Product.UNKNOWN", "Unknown Product");
     if ($product = $this->Product()) {
         Config::nest();
         Config::inst()->update('SSViewer', 'theme_enabled', true);
         $tableTitle = strip_tags($product->renderWith("ProductTableTitle"));
         Config::unnest();
     }
     $updatedTableTitle = $this->extend('updateTableTitle', $tableTitle);
     if ($updatedTableTitle !== null && is_array($updatedTableTitle) && count($updatedTableTitle)) {
         $tableTitle = implode($updatedTableTitle);
     }
     return $tableTitle;
 }
 function setUp()
 {
     parent::setUp();
     // Check versioned available
     if (!class_exists('Versioned')) {
         return $this->markTestSkipped('The versioned decorator is not installed');
     }
     if (self::$index === null) {
         self::$index = singleton('SearchVariantVersionedTest_Index');
     }
     SearchUpdater::bind_manipulation_capture();
     Config::nest();
     Config::inst()->update('Injector', 'SearchUpdateProcessor', array('class' => 'SearchUpdateImmediateProcessor'));
     FullTextSearch::force_index_list(self::$index);
     SearchUpdater::clear_dirty_indexes();
 }
 public function setUp()
 {
     parent::setUp();
     Injector::nest();
     Injector::inst()->unregisterAllObjects();
     // Mock service
     Config::nest();
     Config::inst()->update('Injector', 'AkismetService', 'AkismetTest_Service');
     Config::inst()->update('AkismetSpamProtector', 'api_key', 'dummykey');
     AkismetSpamProtector::set_api_key(null);
     // Reset options to reasonable default
     Config::inst()->remove('AkismetSpamProtector', 'save_spam');
     Config::inst()->remove('AkismetSpamProtector', 'require_confirmation');
     Config::inst()->remove('AkismetSpamProtector', 'bypass_members');
     Config::inst()->update('AkismetSpamProtector', 'bypass_permission', 'ADMIN');
 }
 public function setUp()
 {
     Config::nest();
     // additional nesting here necessary
     Config::inst()->update('File', 'migrate_legacy_file', false);
     parent::setUp();
     // Set backend root to /FileMigrationHelperTest/assets
     AssetStoreTest_SpyStore::activate('FileMigrationHelperTest/assets');
     // Ensure that each file has a local record file in this new assets base
     $from = FRAMEWORK_PATH . '/tests/model/testimages/test-image-low-quality.jpg';
     foreach (File::get()->exclude('ClassName', 'Folder') as $file) {
         $dest = AssetStoreTest_SpyStore::base_path() . '/' . $file->generateFilename();
         SS_Filesystem::makeFolder(dirname($dest));
         copy($from, $dest);
     }
 }
 public function testDefaultClasses()
 {
     Config::nest();
     Config::inst()->update('FormField', 'default_classes', array('class1'));
     $field = new FormField('MyField');
     $this->assertContains('class1', $field->extraClass(), 'Class list does not contain expected class');
     Config::inst()->update('FormField', 'default_classes', array('class1', 'class2'));
     $field = new FormField('MyField');
     $this->assertContains('class1 class2', $field->extraClass(), 'Class list does not contain expected class');
     Config::inst()->update('FormField', 'default_classes', array('class3'));
     $field = new FormField('MyField');
     $this->assertContains('class3', $field->extraClass(), 'Class list does not contain expected class');
     $field->removeExtraClass('class3');
     $this->assertNotContains('class3', $field->extraClass(), 'Class list contains unexpected class');
     Config::inst()->update('TextField', 'default_classes', array('textfield-class'));
     $field = new TextField('MyField');
     //check default classes inherit
     $this->assertContains('class3', $field->extraClass(), 'Class list does not contain inherited class');
     $this->assertContains('textfield-class', $field->extraClass(), 'Class list does not contain expected class');
     Config::unnest();
 }