Merge branch '3.6' into 3

This commit is contained in:
Daniel Hensby 2017-11-14 12:13:08 +00:00
commit 0baa996cc0
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
9 changed files with 54 additions and 7 deletions

View File

@ -29,6 +29,18 @@
}
},
"autoload": {
"classmap": ["tests/behat/features/bootstrap"]
"psr-0": {
"SilverStripe\\": "src/",
"Zend_": "thirdparty/Zend/"
},
"classmap": [
"tests/behat/features/bootstrap",
"admin/code", "api", "cache", "cli", "control", "core", "dev", "email", "filesystem",
"forms", "i18n", "model", "oembed", "parsers", "search", "security", "tasks", "view",
"thirdparty/php-peg", "thirdparty/simpletest", "thirdparty/zend_translate_railsyaml"
],
"exclude-from-classmap": [
"view/SSTemplateParser.php.inc", "dev/phpunit/PhpUnitWrapper.php", "model/fieldtypes/compat"
]
}
}

View File

@ -260,7 +260,7 @@ class Injector {
* @return Injector Reference to new active Injector instance
*/
public static function nest() {
$current = self::$instance;
$current = self::inst();
$new = clone $current;
$new->nestedFrom = $current;

View File

@ -223,7 +223,7 @@ class Config {
* @return Config Reference to new active Config instance
*/
public static function nest() {
$current = self::$instance;
$current = self::inst();
$new = clone $current;
$new->nestedFrom = $current;

View File

@ -171,6 +171,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
public function setUp() {
if (!defined('FRAMEWORK_PATH')) {
trigger_error(
'Missing constants, did you remember to include the test bootstrap in your phpunit.xml file?',
E_USER_WARNING
);
}
//nest config and injector for each test so they are effectively sandboxed per test
Config::nest();
Injector::nest();

View File

@ -10,6 +10,7 @@ Our web-based [PHP installer](installation/) can check if you meet the requireme
* PHP 5.3.3+, <7.2
* We recommend using a PHP accelerator or opcode cache, such as [xcache](http://xcache.lighttpd.net/) or [WinCache](http://www.iis.net/download/wincacheforphp).
* Note: Some PHP 5.5+ packages already have [Zend OpCache](http://php.net/manual/en/book.opcache.php) installed by default. If this is the case on your system, do not try and run additional opcaches alongside Zend OpCache without first disabling it, as it will likely have unexpected consequences.
* Allocate at least 48MB of memory to each PHP process. (SilverStripe can be resource hungry for some intensive operations.)
* Required modules: dom, gd2, fileinfo, hash, iconv, mbstring, mysqli (or other database driver), session, simplexml, tokenizer, xml.
* Recommended configuration

View File

@ -634,7 +634,7 @@ class File extends DataObject {
*
* Does not change the filesystem itself, please use {@link write()} for this.
*
* @param String $name
* @param string $name
*/
public function setName($name) {
$oldName = $this->Name;
@ -663,7 +663,10 @@ class File extends DataObject {
))->first()
) {
$suffix++;
$name = "$base-$suffix.$ext";
$name = "$base-$suffix";
if (!empty($ext)) {
$name .= ".$ext";
}
}
}

View File

@ -3225,7 +3225,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$SNG = singleton($callerClass);
$cacheComponents = array($filter, $orderby, $SNG->extend('cacheKeyComponent'));
$cacheKey = md5(var_export($cacheComponents, true));
$cacheKey = md5(serialize($cacheComponents));
// Flush destroyed items out of the cache
if($cache && isset(DataObject::$_cache_get_one[$callerClass][$cacheKey])

View File

@ -187,6 +187,30 @@ class FileTest extends SapphireTest {
}
}
/**
* Uses fixtures Folder.folder1 and File.setfromname
* @dataProvider setNameFileProvider
*/
public function testSetNameAddsUniqueSuffixWhenFilenameAlreadyExists($name, $expected)
{
$duplicate = new Folder;
$duplicate->setName($name);
$duplicate->write();
$this->assertSame($expected, $duplicate->Name);
}
/**
* @return array[]
*/
public function setNameFileProvider()
{
return array(
array('FileTest-folder1', 'FileTest-folder1-2'),
array('FileTest.png', 'FileTest-2.png'),
);
}
public function testLinkAndRelativeLink() {
$file = $this->objFromFixture('File', 'asdf');
$this->assertEquals(ASSETS_DIR . '/FileTest.txt', $file->RelativeLink());

View File

@ -63,7 +63,7 @@ class DataQueryTest extends SapphireTest {
$this->assertContains('"DataQueryTest_C"."ID" = "DataQueryTest_B"."TestCTwoID"', $dq->sql());
}
public function testApplyReplationDeepInheretence() {
public function testApplyRelationDeepInheritance() {
//test has_one relation
$newDQ = new DataQuery('DataQueryTest_E');
//apply a relation to a relation from an ancestor class