예제 #1
0
	static function set_up_once() {
		// needs to recreate the database schema with language properties
		self::kill_temp_db();

		// store old defaults	
		if(class_exists('Translatable')) {
			self::$origTranslatableSettings['has_extension'] = singleton('SiteTree')->hasExtension('Translatable');
			self::$origTranslatableSettings['default_locale'] = Translatable::default_locale();
			
			// overwrite locale
			Translatable::set_default_locale("en_US");

			// refresh the extended statics - different fields in $db with Translatable enabled
			if(self::$origTranslatableSettings['has_extension']) {
				Object::remove_extension('SiteTree', 'Translatable');
				Object::remove_extension('SiteConfig', 'Translatable');
			}
		}

		// recreate database with new settings
		$dbname = self::create_temp_db();
		DB::set_alternative_database_name($dbname);

		parent::set_up_once();
	}
 function testRebuildZendSearchLuceneIndex()
 {
     // Setup
     Object::remove_extension('ContentController', 'ZendSearchLuceneContentController');
     Object::remove_extension('SiteConfig', 'ZendSearchLuceneSiteConfig');
     Object::remove_extension('LeftAndMain', 'ZendSearchLuceneCMSDecorator');
     Object::remove_extension('SiteTree', 'ZendSearchLuceneSearchable');
     Object::remove_extension('File', 'ZendSearchLuceneSearchable');
     ZendSearchLuceneSearchable::$pageLength = 10;
     ZendSearchLuceneSearchable::$alwaysShowPages = 3;
     ZendSearchLuceneSearchable::$maxShowPages = 8;
     ZendSearchLuceneSearchable::$encoding = 'utf-8';
     ZendSearchLuceneSearchable::$cacheDirectory = TEMP_FOLDER;
     ZendSearchLuceneWrapper::$indexName = 'Test';
     ZendSearchLuceneSearchable::enable();
     $index = ZendSearchLuceneWrapper::getIndex(true);
     // Blank database
     $this->assertEquals(0, $index->count());
     // Count number of SiteTree and File objects
     $SiteTreeCount = DataObject::get('SiteTree')->count();
     $FileCount = DataObject::get('File')->count();
     $IndexableCount = $SiteTreeCount + $FileCount;
     // Re-index database
     $obj = new ZendSearchLuceneCMSDecorator();
     $obj->rebuildZendSearchLuceneIndex();
     // Has correct number of items?
     $this->assertEquals($IndexableCount, ZendSearchLuceneWrapper::getIndex()->count());
 }
예제 #3
0
 function tearDown()
 {
     Object::remove_extension("SiteTree", "FilesystemPublisher('../FilesystemPublisherTest-static-folder/')");
     SiteTree::$write_homepage_map = true;
     FilesystemPublisher::$domain_based_caching = $this->orig['domain_based_caching'];
     parent::tearDown();
 }
예제 #4
0
 /**
  * Removes commenting from a {@link DataObject}. Does not remove existing comments
  * but does remove the extension.
  *
  * @param string $class Class to remove {@link CommentsExtension} from
  */
 public static function remove($class)
 {
     if (isset(self::$enabled_classes[$class])) {
         unset(self::$enabled_classes[$class]);
     }
     Object::remove_extension($class, 'CommentsExtension');
 }
예제 #5
0
 public function testEnableWithCustomClasses()
 {
     FulltextSearchable::enable(array('File'));
     $this->assertTrue(Object::has_extension('File', 'FulltextSearchable'));
     // TODO This shouldn't need all arguments included
     Object::remove_extension('File', 'FulltextSearchable(\'"Filename","Title","Content"\')');
     $this->assertFalse(Object::has_extension('File', 'FulltextSearchable'));
 }
예제 #6
0
 public static function remove_weight($weight)
 {
     self::$weights = array_diff(self::$weights, array($weight));
     $class = "NewsWeight{$weight}";
     if (ClassInfo::exists($class)) {
         Object::remove_extension('NewsHolder', $class);
     }
 }
 function tearDown()
 {
     parent::tearDown();
     Object::remove_extension("SiteTree", "FilesystemPublisher('assets/FilesystemPublisherTest-static-folder/')");
     FilesystemPublisher::$domain_based_caching = $this->orig['domain_based_caching'];
     if (file_exists(BASE_PATH . '/assets/FilesystemPublisherTest-static-folder')) {
         Filesystem::removeFolder(BASE_PATH . '/assets/FilesystemPublisherTest-static-folder');
     }
 }
 static function tear_down_once()
 {
     if (!self::$origTranslatableSettings['has_extension']) {
         Object::remove_extension('SiteTree', 'Translatable');
     }
     Translatable::set_default_locale(self::$origTranslatableSettings['default_locale']);
     self::kill_temp_db();
     self::create_temp_db();
     parent::tear_down_once();
 }
 function testUpdateCMSActions()
 {
     // Setup
     Object::remove_extension('ContentController', 'ZendSearchLuceneContentController');
     Object::remove_extension('SiteConfig', 'ZendSearchLuceneSiteConfig');
     Object::remove_extension('LeftAndMain', 'ZendSearchLuceneCMSDecorator');
     Object::remove_extension('SiteTree', 'ZendSearchLuceneSearchable');
     Object::remove_extension('File', 'ZendSearchLuceneSearchable');
     ZendSearchLuceneSearchable::$pageLength = 10;
     ZendSearchLuceneSearchable::$alwaysShowPages = 3;
     ZendSearchLuceneSearchable::$maxShowPages = 8;
     ZendSearchLuceneSearchable::$encoding = 'utf-8';
     ZendSearchLuceneSearchable::$cacheDirectory = TEMP_FOLDER;
     ZendSearchLuceneWrapper::$indexName = 'Test';
     ZendSearchLuceneSearchable::enable(array());
     $config = SiteConfig::current_site_config();
     $this->assertTrue(is_object($config->getCMSActions()->fieldByName('rebuildZendSearchLuceneIndex')));
 }
 /**
  * tearDown method that's called once per test class rather once per test method.
  */
 function tearDownOnce()
 {
     // If we have made changes to the extensions present, then migrate the database schema.
     if ($this->extensionsToReapply || $this->extensionsToRemove) {
         // Remove extensions added for testing
         foreach ($this->extensionsToRemove as $class => $extensions) {
             foreach ($extensions as $extension) {
                 Object::remove_extension($class, $extension);
             }
         }
         // Reapply ones removed
         foreach ($this->extensionsToReapply as $class => $extensions) {
             foreach ($extensions as $extension) {
                 Object::add_extension($class, $extension);
             }
         }
     }
     if ($this->extensionsToReapply || $this->extensionsToRemove || $this->extraDataObjects) {
         $this->resetDBSchema();
     }
 }
예제 #11
0
 /**
  * Remove given extensions from Member. This is useful for
  * removing extensions that could produce a biased
  * test result, as some extensions applied by project
  * code or modules can do this.
  * 
  * @param array $extensions
  * @return array The removed extensions
  */
 protected function removeExtensions($extensions)
 {
     if ($extensions) {
         foreach ($extensions as $extension) {
             Object::remove_extension('Member', $extension);
         }
     }
     return $extensions;
 }
 public function testOnAfterDelete()
 {
     // Setup
     Object::remove_extension('SiteTree', 'ZendSearchLuceneSearchable');
     Object::remove_extension('File', 'ZendSearchLuceneSearchable');
     ZendSearchLuceneSearchable::$pageLength = 10;
     ZendSearchLuceneSearchable::$alwaysShowPages = 3;
     ZendSearchLuceneSearchable::$maxShowPages = 8;
     ZendSearchLuceneSearchable::$encoding = 'utf-8';
     ZendSearchLuceneSearchable::$cacheDirectory = TEMP_FOLDER;
     ZendSearchLuceneWrapper::$indexName = 'Test';
     ZendSearchLuceneSearchable::enable();
     // Blank the index
     ZendSearchLuceneWrapper::getIndex(true);
     // There shouldn't be anything with asdf in there
     $this->assertEquals(0, count(ZendSearchLuceneWrapper::find('asdf')));
     $page = DataObject::get_one('Page');
     $page->Content = 'asdf';
     $page->write();
     // There should now be a result
     $this->assertGreaterThan(0, count(ZendSearchLuceneWrapper::find('asdf')));
     $page->delete();
     // There should now be no result again
     $this->assertEquals(0, count(ZendSearchLuceneWrapper::find('asdf')));
 }
예제 #13
0
 /**
  * Disable the multilingual feature
  *
  * @deprecated 2.4 Use Object::remove_extension('SiteTree', 'Translatable')
  */
 static function disable()
 {
     Object::remove_extension('SiteTree', 'Translatable');
 }
 public static function remove_sortable_class($class)
 {
     Object::remove_extension($class, 'SortableDataObject');
 }
 /**
  * Disable the multilingual feature
  *
  * @deprecated 2.4 Use Object::remove_extension('SiteTree', 'Translatable')
  */
 static function disable()
 {
     if (class_exists('SiteTree')) {
         Object::remove_extension('SiteTree', 'Translatable');
     }
 }
예제 #16
0
 public function testRemoveExtension()
 {
     // manually add ObjectTest_ExtendTest2
     Object::add_extension('ObjectTest_ExtensionRemoveTest', 'ObjectTest_ExtendTest2');
     $this->assertTrue(Object::has_extension('ObjectTest_ExtensionRemoveTest', 'ObjectTest_ExtendTest2'), "Extension added through \$add_extension() are added correctly");
     Object::remove_extension('ObjectTest_ExtensionRemoveTest', 'ObjectTest_ExtendTest2');
     $this->assertFalse(Object::has_extension('ObjectTest_ExtensionRemoveTest', 'ObjectTest_ExtendTest2'), "Extension added through \$add_extension() are detected as removed in has_extension()");
     $this->assertFalse(singleton('ObjectTest_ExtensionRemoveTest')->hasExtension('ObjectTest_ExtendTest2'), "Extensions added through \$add_extension() are detected as removed in instances through hasExtension()");
     // ObjectTest_ExtendTest1 is already present in $extensions
     Object::remove_extension('ObjectTest_ExtensionRemoveTest', 'ObjectTest_ExtendTest1');
     $this->assertFalse(Object::has_extension('ObjectTest_ExtensionRemoveTest', 'ObjectTest_ExtendTest1'), "Extension added through \$extensions are detected as removed in has_extension()");
     $objectTest_ExtensionRemoveTest = new ObjectTest_ExtensionRemoveTest();
     $this->assertFalse($objectTest_ExtensionRemoveTest->hasExtension('ObjectTest_ExtendTest1'), "Extensions added through \$extensions are detected as removed in instances through hasExtension()");
 }
<?php

/**
 * @package silverstripe-newsletter-tracking
 */
Director::addRules(50, array('newsletter-link' => 'NewsletterLinkController', 'newsletter-view' => 'NewsletterViewController'));
Object::remove_extension('NewsletterEmail', 'TrackingLinksEmail');
Object::add_extension('Member', 'NewsletterTrackingMemberExtension');
Object::add_extension('Newsletter', 'NewsletterTrackingExtension');
Object::add_extension('NewsletterEmail', 'NewsletterEmailLinkTrackingExtension');
Object::add_extension('NewsletterEmail', 'NewsletterEmailViewTrackingExtension');
Object::add_extension('Newsletter_TrackedLink', 'NewsletterTrackedLinkTrackingExtension');