public function setUp() { parent::setUp(); // This test tests code that was deprecated after 2.4 $this->originalDeprecation = Deprecation::dump_settings(); Deprecation::notification_version('2.4'); }
public function testGetArray() { $originalDeprecation = Deprecation::dump_settings(); Deprecation::notification_version('2.4'); $array = array('Foo' => 'Foo', 'Bar' => 'Bar', 'Baz' => 'Baz'); $arrayData = new ArrayData($array); $this->assertEquals($arrayData->toMap(), $array); Deprecation::restore_settings($originalDeprecation); }
/** * Test the Group::map() function */ public function testGroupMap() { // 2.4 only $originalDeprecation = Deprecation::dump_settings(); Deprecation::notification_version('2.4'); /* Group::map() returns an SQLMap object implementing iterator. You can use foreach to get ID-Title pairs. */ // We will iterate over the map and build mapOuput to more easily call assertions on the result. $map = Group::map(); $mapOutput = $map->toArray(); $group1 = $this->objFromFixture('Group', 'group1'); $group2 = $this->objFromFixture('Group', 'group2'); /* We have added 2 groups to our fixture. They should both appear in $mapOutput. */ $this->assertEquals($mapOutput[$group1->ID], $group1->Title); $this->assertEquals($mapOutput[$group2->ID], $group2->Title); Deprecation::restore_settings($originalDeprecation); }
public function testRewriteTabPathFindOrMakeTab() { $originalDeprecation = Deprecation::dump_settings(); Deprecation::notification_version('2.4'); $fields = new FieldList(new Tabset("Root", $tab1Level1 = new Tab("Tab1Level1Renamed", $tab1Level2 = new Tab("Tab1Level2"), $tab2Level2 = new Tab("Tab2Level2")), $tab2Level1 = new Tab("Tab2Level1"))); $fields->setTabPathRewrites(array('/Root\\.Tab1Level1\\.([^.]+)$/' => 'Root.Tab1Level1Renamed.\\1', '/Root\\.Tab1Level1$/' => 'Root.Tab1Level1Renamed')); $this->assertEquals($tab1Level1, $fields->findOrMakeTab('Root.Tab1Level1'), 'findOrMakeTab() with toplevel tab under old name'); $this->assertEquals($tab1Level1, $fields->findOrMakeTab('Root.Tab1Level1Renamed'), 'findOrMakeTab() with toplevel tab under new name'); $this->assertEquals($tab1Level2, $fields->findOrMakeTab('Root.Tab1Level1.Tab1Level2'), 'findOrMakeTab() with nested tab under old parent tab name'); $this->assertEquals($tab1Level2, $fields->findOrMakeTab('Root.Tab1Level1Renamed.Tab1Level2'), 'findOrMakeTab() with nested tab under new parent tab name'); Deprecation::restore_settings($originalDeprecation); }
<?php Deprecation::notification_version('1.0', 'retinaimages'); define('RETINA_MODULE_DIR', dirname(__FILE__)); Object::useCustomClass('Image', 'RetinaImage'); Object::useCustomClass('Image_Cached', 'RetinaImage_Cached'); // SiteTree uses new HtmlEditorField() instead of HtmlEditorField::create() // as a result if you want retina images in your WYSIWYG editor you'll need to // recreate the HtmlEditorField. Object::useCustomClass('HtmlEditorField', 'RetinaImageHtmlEditorField'); // tinyCMS additional HTML5 elements $wysiwyg = HtmlEditorConfig::get('cms')->getOption('valid_elements'); $wysiwyg .= ',-img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align|data*|srcset]'; HtmlEditorConfig::get('cms')->setOption('valid_elements', $wysiwyg);
/** * @expectedException PHPUnit_Framework_Error */ function testMatchingModuleNotifcationVersionAffectsNotice() { Deprecation::notification_version('1.0.0'); Deprecation::notification_version('3.0.0', FRAMEWORK_DIR); $this->callThatOriginatesFromFramework(); }
/** * @expectedException PHPUnit_Framework_Error * @expectedExceptionMessage Global scope */ public function testScopeGlobal() { Deprecation::notification_version('2.0.0'); Deprecation::notice('2.0.0', 'Global scope', Deprecation::SCOPE_GLOBAL); }
<?php global $databaseConfig; if (isset($databaseConfig['type'])) { SearchUpdater::bind_manipulation_capture(); } Deprecation::notification_version('1.0.0', 'fulltextsearch');
<?php Deprecation::notification_version('1.4.0', 'sqlite3');
/** * Test methods that get DataObjects * - DataObject::get() * - All records of a DataObject * - Filtering * - Sorting * - Joins * - Limit * - Container class * - DataObject::get_by_id() * - DataObject::get_one() * - With and without caching * - With and without ordering */ public function testGet() { // Test getting all records of a DataObject $comments = DataObject::get('DataObjectTest_TeamComment'); $this->assertEquals(3, $comments->Count()); // Test WHERE clause $comments = DataObject::get('DataObjectTest_TeamComment', "\"Name\"='Bob'"); $this->assertEquals(1, $comments->Count()); foreach ($comments as $comment) { $this->assertEquals('Bob', $comment->Name); } // Test sorting $comments = DataObject::get('DataObjectTest_TeamComment', '', "\"Name\" ASC"); $this->assertEquals(3, $comments->Count()); $this->assertEquals('Bob', $comments->First()->Name); $comments = DataObject::get('DataObjectTest_TeamComment', '', "\"Name\" DESC"); $this->assertEquals(3, $comments->Count()); $this->assertEquals('Phil', $comments->First()->Name); // Test join - 2.4 only $originalDeprecation = Deprecation::dump_settings(); Deprecation::notification_version('2.4'); $comments = DataObject::get('DataObjectTest_TeamComment', "\"DataObjectTest_Team\".\"Title\" = 'Team 1'", "\"Name\" ASC", "INNER JOIN \"DataObjectTest_Team\"" . " ON \"DataObjectTest_TeamComment\".\"TeamID\" = \"DataObjectTest_Team\".\"ID\""); $this->assertEquals(2, $comments->Count()); $this->assertEquals('Bob', $comments->First()->Name); $this->assertEquals('Joe', $comments->Last()->Name); Deprecation::restore_settings($originalDeprecation); // Test limit $comments = DataObject::get('DataObjectTest_TeamComment', '', "\"Name\" ASC", '', '1,2'); $this->assertEquals(2, $comments->Count()); $this->assertEquals('Joe', $comments->First()->Name); $this->assertEquals('Phil', $comments->Last()->Name); // Test get_by_id() $captain1ID = $this->idFromFixture('DataObjectTest_Player', 'captain1'); $captain1 = DataObject::get_by_id('DataObjectTest_Player', $captain1ID); $this->assertEquals('Captain', $captain1->FirstName); // Test get_one() without caching $comment1 = DataObject::get_one('DataObjectTest_TeamComment', "\"Name\" = 'Joe'", false); $comment1->Comment = "Something Else"; $comment2 = DataObject::get_one('DataObjectTest_TeamComment', "\"Name\" = 'Joe'", false); $this->assertNotEquals($comment1->Comment, $comment2->Comment); // Test get_one() with caching $comment1 = DataObject::get_one('DataObjectTest_TeamComment', "\"Name\" = 'Bob'", true); $comment1->Comment = "Something Else"; $comment2 = DataObject::get_one('DataObjectTest_TeamComment', "\"Name\" = 'Bob'", true); $this->assertEquals((string) $comment1->Comment, (string) $comment2->Comment); // Test get_one() with order by without caching $comment = DataObject::get_one('DataObjectTest_TeamComment', '', false, "\"Name\" ASC"); $this->assertEquals('Bob', $comment->Name); $comment = DataObject::get_one('DataObjectTest_TeamComment', '', false, "\"Name\" DESC"); $this->assertEquals('Phil', $comment->Name); // Test get_one() with order by with caching $comment = DataObject::get_one('DataObjectTest_TeamComment', '', true, '"Name" ASC'); $this->assertEquals('Bob', $comment->Name); $comment = DataObject::get_one('DataObjectTest_TeamComment', '', true, '"Name" DESC'); $this->assertEquals('Phil', $comment->Name); }
<?php if (!defined('USERFORMS_DIR')) { define('USERFORMS_DIR', basename(__DIR__)); } Deprecation::notification_version('3.0', 'userforms');
/** * Test deprecation of SQLQuery::setDelete/getDelete */ public function testDeprecatedSetDelete() { // Temporarily disable deprecation Deprecation::notification_version(null); $query = new SQLQuery(); $query->setSelect(array('"SQLQueryTest_DO"."Name"')); $query->setFrom('"SQLQueryTest_DO"'); $query->setWhere(array('"SQLQueryTest_DO"."Name"' => 'Andrew')); // Check SQL for select $this->assertSQLEquals(<<<EOS SELECT "SQLQueryTest_DO"."Name" FROM "SQLQueryTest_DO" WHERE ("SQLQueryTest_DO"."Name" = ?) EOS , $query->sql($parameters)); $this->assertEquals(array('Andrew'), $parameters); // Check setDelete works $query->setDelete(true); $this->assertSQLEquals(<<<EOS DELETE FROM "SQLQueryTest_DO" WHERE ("SQLQueryTest_DO"."Name" = ?) EOS , $query->sql($parameters)); $this->assertEquals(array('Andrew'), $parameters); // Check that setDelete back to false restores the state $query->setDelete(false); $this->assertSQLEquals(<<<EOS SELECT "SQLQueryTest_DO"."Name" FROM "SQLQueryTest_DO" WHERE ("SQLQueryTest_DO"."Name" = ?) EOS , $query->sql($parameters)); $this->assertEquals(array('Andrew'), $parameters); }
<?php /** * Default configuration settings for the Spam Protection module. * * You should not put your own configuration in here rather use your * mysite/_config.php file * * @package spamprotection */ Deprecation::notification_version('1.1', 'spamprotection');
<?php Requirements::set_backend(new SSGuru_Requirements_Backend()); define('SS_GDM_EXTENSIONS_DIR', basename(dirname(__FILE__))); Deprecation::notification_version("0.1.3", SS_GDM_EXTENSIONS_DIR);
<?php if (!defined('SS_MWM_DIR')) { define('SS_MWM_DIR', basename(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR))); } Requirements::set_backend(new \Milkyway\SS\Core\RequirementsBackend()); // Register all shortcodes for use with injector and shortcodable module Milkyway\SS\Shortcodes\Extensions\ShortcodableController::register(); Deprecation::notification_version('0.2', 'mwm-utilities'); /** * Credit for following functions goes to taylorotwell (laravel/framework) * * @credit taylorotwell (laravel/framework) * @licence MIT */ if (!function_exists('with')) { /** * Return the given object. Useful for chaining. * * @param mixed $object * @return mixed */ function with($object) { return $object; } } if (!function_exists('array_set')) { /** * Set an array item to a given value using "dot" notation. *
public function testURLParams() { // 2.4 only $originalDeprecation = Deprecation::dump_settings(); Deprecation::notification_version('2.4'); Director::test('DirectorTestRule/myaction/myid/myotherid'); // TODO Works on the assumption that urlParam() is not unset after a test run, which is dodgy $this->assertEquals(Director::urlParams(), array('Controller' => 'DirectorTestRequest_Controller', 'Action' => 'myaction', 'ID' => 'myid', 'OtherID' => 'myotherid')); Deprecation::restore_settings($originalDeprecation); }
<?php Deprecation::notification_version('0.2', 'polls');
<?php Deprecation::notification_version('2.0', 'comments'); define('COMMENTS_DIR', basename(__DIR__)); define('COMMENTS_THIRDPARTY', COMMENTS_DIR . DIRECTORY_SEPARATOR . 'thirdparty');
<?php /** * Framework configuration file * * Here you can make different settings for the Framework module (the core * module). * * For example you can register the authentication methods you wish to use * on your site, e.g. to register the OpenID authentication method type * * <code> * Authenticator::register_authenticator('OpenIDAuthenticator'); * </code> * * @package framework * @subpackage core */ ShortcodeParser::get('default')->register('file_link', array('File', 'handle_shortcode'))->register('embed', array('Oembed', 'handle_shortcode')); // @todo // ->register('dbfile_link', array('DBFile', 'handle_shortcode')) // Zend_Cache temp directory setting $_ENV['TMPDIR'] = TEMP_FOLDER; // for *nix $_ENV['TMP'] = TEMP_FOLDER; // for Windows SS_Cache::set_cache_lifetime('GDBackend_Manipulations', null, 100); // If you don't want to see deprecation errors for the new APIs, change this to 3.2.0-dev. Deprecation::notification_version('3.2.0'); // TODO Remove once new ManifestBuilder with submodule support is in place require_once 'admin/_config.php';
<?php Deprecation::notification_version('1.1.0', 'deploynaut'); // *.sspak is required for data archives $exts = Config::inst()->get('File', 'allowed_extensions'); $exts[] = 'sspak'; Config::inst()->update('File', 'allowed_extensions', $exts);
<?php Deprecation::notification_version('1.0', 'staticpublisher'); define('STATIC_MODULE_DIR', dirname(__FILE__));