Merge branch '3.6' into 3

This commit is contained in:
Daniel Hensby 2017-11-25 16:18:46 +00:00
commit fd201bc71b
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
17 changed files with 54 additions and 40 deletions

View File

@ -8,6 +8,7 @@ addons:
apt: apt:
packages: packages:
- tidy - tidy
firefox: "31.0"
matrix: matrix:
include: include:
@ -32,8 +33,8 @@ matrix:
before_script: before_script:
- export CORE_RELEASE=$TRAVIS_BRANCH - export CORE_RELEASE=$TRAVIS_BRANCH
- if ! [ $(phpenv version-name) = "5.3" ]; then printf "\n" | pecl install imagick; fi - if ! [ $(phpenv version-name) = "5.3" ]; then printf "\n" | travis_retry pecl install imagick; fi
- if [ $(phpenv version-name) = "5.3" ]; then printf "\n" | pecl install imagick-3.3.0; fi - if [ $(phpenv version-name) = "5.3" ]; then printf "\n" | travis_retry pecl install imagick-3.3.0; fi
- composer self-update || true - composer self-update || true
- phpenv rehash - phpenv rehash
- phpenv config-rm xdebug.ini - phpenv config-rm xdebug.ini

View File

@ -22,5 +22,13 @@ Injector:
type: prototype type: prototype
Int: Int:
class: DBInt class: DBInt
int:
class: DBInt
INT:
class: DBInt
Float: Float:
class: DBFloat class: DBFloat
float:
class: DBFloat
FLOAT:
class: DBFloat

View File

@ -21,7 +21,7 @@
"mustangostang/spyc": "^0.6.2" "mustangostang/spyc": "^0.6.2"
}, },
"require-dev": { "require-dev": {
"phpunit/PHPUnit": "~3.7" "phpunit/phpunit": "^3 || ^4 || ^5"
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {

View File

@ -810,9 +810,13 @@ class Director implements TemplateGlobalProvider {
/** /**
* Skip any further processing and immediately respond with a redirect to the passed URL. * Skip any further processing and immediately respond with a redirect to the passed URL.
* *
* @param string $destURL - The URL to redirect to * @param string $destURL The URL to redirect to
* @return string URL redirected to if on CLI
*/ */
protected static function force_redirect($destURL) { protected static function force_redirect($destURL) {
if (static::is_cli()) {
return $destURL;
}
$response = new SS_HTTPResponse(); $response = new SS_HTTPResponse();
$response->redirect($destURL, 301); $response->redirect($destURL, 301);
@ -859,9 +863,6 @@ class Director implements TemplateGlobalProvider {
$matched = false; $matched = false;
if($patterns) { if($patterns) {
// Calling from the command-line?
if(!isset($_SERVER['REQUEST_URI'])) return;
$relativeURL = self::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI'])); $relativeURL = self::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI']));
// protect portions of the site based on the pattern // protect portions of the site based on the pattern
@ -887,12 +888,7 @@ class Director implements TemplateGlobalProvider {
$destURL = str_replace('http:', 'https:', Director::absoluteURL($url)); $destURL = str_replace('http:', 'https:', Director::absoluteURL($url));
// This coupling to SapphireTest is necessary to test the destination URL and to not interfere with tests return self::force_redirect($destURL);
if(class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
return $destURL;
} else {
self::force_redirect($destURL);
}
} else { } else {
return false; return false;
} }

View File

@ -271,7 +271,7 @@ class HTTP {
// Fallback to use the list from the HTTP.yml configuration and rely on the file extension // Fallback to use the list from the HTTP.yml configuration and rely on the file extension
// to get the file mime-type // to get the file mime-type
$ext = File::get_file_extension($filename); $ext = strtolower(File::get_file_extension($filename));
// Get the mime-types // Get the mime-types
$mimeTypes = Config::inst()->get('HTTP', 'MimeTypes'); $mimeTypes = Config::inst()->get('HTTP', 'MimeTypes');

View File

@ -93,13 +93,14 @@ class HtmlEditorField extends TextareaField {
$img->setAttribute('src', preg_replace('/([^\?]*)\?r=[0-9]+$/i', '$1', $img->getAttribute('src'))); $img->setAttribute('src', preg_replace('/([^\?]*)\?r=[0-9]+$/i', '$1', $img->getAttribute('src')));
// Resample the images if the width & height have changed. // Resample the images if the width & height have changed.
if($image = File::find(urldecode(Director::makeRelative($img->getAttribute('src'))))){ $image = File::find(urldecode(Director::makeRelative($img->getAttribute('src'))));
if($image instanceof Image){
$width = (int)$img->getAttribute('width'); $width = (int)$img->getAttribute('width');
$height = (int)$img->getAttribute('height'); $height = (int)$img->getAttribute('height');
if($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) { if($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) {
//Make sure that the resized image actually returns an image: //Make sure that the resized image actually returns an image:
$resized=$image->ResizedImage($width, $height); $resized = $image->ResizedImage($width, $height);
if($resized) $img->setAttribute('src', $resized->getRelativePath()); if($resized) $img->setAttribute('src', $resized->getRelativePath());
} }
} }

View File

@ -47,7 +47,7 @@
// XMLHttpRequest // XMLHttpRequest
CurrentXhr: null, CurrentXhr: null,
onadd: function() { onmatch: function() {
this.append( this.append(
'<span class="treedropdownfield-title"></span>' + '<span class="treedropdownfield-title"></span>' +
'<div class="treedropdownfield-toggle-panel-link"><a href="#" class="ui-icon ui-icon-triangle-1-s"></a></div>' + '<div class="treedropdownfield-toggle-panel-link"><a href="#" class="ui-icon ui-icon-triangle-1-s"></a></div>' +
@ -334,7 +334,7 @@
}); });
$('.TreeDropdownField.searchable').entwine({ $('.TreeDropdownField.searchable').entwine({
onadd: function() { onmatch: function() {
this._super(); this._super();
var title = ss.i18n._t('TreeDropdownField.ENTERTOSEARCH'); var title = ss.i18n._t('TreeDropdownField.ENTERTOSEARCH');
this.find('.treedropdownfield-panel').prepend( this.find('.treedropdownfield-panel').prepend(
@ -431,13 +431,13 @@
}); });
$('.TreeDropdownField input[type=hidden]').entwine({ $('.TreeDropdownField input[type=hidden]').entwine({
onadd: function() { onmatch: function() {
this._super(); this._super();
this.bind('change.TreeDropdownField', function() { this.bind('change.TreeDropdownField', function() {
$(this).getField().updateTitle(); $(this).getField().updateTitle();
}); });
}, },
onremove: function() { onunmatch: function() {
this._super(); this._super();
this.unbind('.TreeDropdownField'); this.unbind('.TreeDropdownField');
} }

View File

@ -755,7 +755,7 @@ class DataQuery {
list($parentClass, $componentClass, $parentField, $componentField, $relationTable) = $component; list($parentClass, $componentClass, $parentField, $componentField, $relationTable) = $component;
$parentBaseClass = ClassInfo::baseDataClass($parentClass); $parentBaseClass = ClassInfo::baseDataClass($parentClass);
$componentBaseClass = ClassInfo::baseDataClass($componentClass); $componentBaseClass = ClassInfo::baseDataClass($componentClass);
$this->query->addInnerJoin($relationTable, $this->query->addLeftJoin($relationTable,
"\"$relationTable\".\"$parentField\" = \"$parentBaseClass\".\"ID\""); "\"$relationTable\".\"$parentField\" = \"$parentBaseClass\".\"ID\"");
if (!$this->query->isJoinedTo($componentBaseClass)) { if (!$this->query->isJoinedTo($componentBaseClass)) {
$this->query->addLeftJoin($componentBaseClass, $this->query->addLeftJoin($componentBaseClass,

View File

@ -1100,7 +1100,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
$fromRecord = Versioned::get_version($this->owner->class, $this->owner->ID, $from); $fromRecord = Versioned::get_version($this->owner->class, $this->owner->ID, $from);
$toRecord = Versioned::get_version($this->owner->class, $this->owner->ID, $to); $toRecord = Versioned::get_version($this->owner->class, $this->owner->ID, $to);
$diff = new DataDifferencer($fromRecord, $toRecord); $diff = DataDifferencer::create($fromRecord, $toRecord);
return $diff->diffedData(); return $diff->diffedData();
} }

View File

@ -179,6 +179,7 @@ class HTTPTest extends FunctionalTest {
$this->assertEquals('image/gif', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.gif')); $this->assertEquals('image/gif', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.gif'));
$this->assertEquals('text/html', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.html')); $this->assertEquals('text/html', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.html'));
$this->assertEquals('image/jpeg', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.jpg')); $this->assertEquals('image/jpeg', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.jpg'));
$this->assertEquals('image/jpeg', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/upperfile.JPG'));
$this->assertEquals('image/png', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.png')); $this->assertEquals('image/png', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.png'));
$this->assertEquals('image/vnd.adobe.photoshop', $this->assertEquals('image/vnd.adobe.photoshop',
HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.psd')); HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.psd'));

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

View File

@ -30,13 +30,10 @@ class ConfigManifestTest extends SapphireTest {
* @return Zend_Cache_Core * @return Zend_Cache_Core
*/ */
protected function getCacheMock() { protected function getCacheMock() {
return $this->getMock( return $this->getMockBuilder('Zend_Cache_Core')
'Zend_Cache_Core', ->setMethods(array('load', 'save'))
array('load', 'save'), ->disableOriginalConstructor()
array(), ->getMock();
'',
false
);
} }
/** /**
@ -45,13 +42,10 @@ class ConfigManifestTest extends SapphireTest {
* @return SS_ConfigManifest * @return SS_ConfigManifest
*/ */
protected function getManifestMock($methods) { protected function getManifestMock($methods) {
return $this->getMock( return $this->getMockBuilder('SS_ConfigManifest')
'SS_ConfigManifest', ->setMethods($methods)
$methods, ->disableOriginalConstructor()
array(), // no constructor arguments ->getMock();
'', // default
false // don't call the constructor
);
} }
/** /**

View File

@ -605,7 +605,7 @@ class InjectorTest extends SapphireTest {
'service' => array('factory' => 'factory', 'constructor' => array(1, 2, 3)) 'service' => array('factory' => 'factory', 'constructor' => array(1, 2, 3))
)); ));
$factory = $this->getMock('SilverStripe\\Framework\\Injector\\Factory'); $factory = $this->getMockBuilder('SilverStripe\\Framework\\Injector\\Factory')->getMock();
$factory $factory
->expects($this->once()) ->expects($this->once())
->method('create') ->method('create')

View File

@ -774,6 +774,15 @@ class DataListTest extends SapphireTest {
$this->assertEquals(1, $list->count()); $this->assertEquals(1, $list->count());
} }
public function testFilterAnyWithRelation() {
$list = DataObjectTest_Player::get();
$list = $list->filterAny(array(
'Teams.Title:StartsWith' => 'Team',
'ID:GreaterThan' => 0,
));
$this->assertCount(4, $list);
}
public function testFilterAnyMultipleArray() { public function testFilterAnyMultipleArray() {
$list = DataObjectTest_TeamComment::get(); $list = DataObjectTest_TeamComment::get();
$list = $list->filterAny(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob')); $list = $list->filterAny(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob'));

View File

@ -43,7 +43,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testSetPaginationFromQuery() { public function testSetPaginationFromQuery() {
$query = $this->getMock('SQLQuery'); $query = $this->getMockBuilder('SQLQuery')->getMock();
$query->expects($this->once()) $query->expects($this->once())
->method('getLimit') ->method('getLimit')
->will($this->returnValue(array('limit' => 15, 'start' => 30))); ->will($this->returnValue(array('limit' => 15, 'start' => 30)));

View File

@ -277,7 +277,9 @@ class ShortcodeParserTest extends SapphireTest {
} }
public function testNoParseAttemptIfNoCode() { public function testNoParseAttemptIfNoCode() {
$stub = $this->getMock('ShortcodeParser', array('replaceElementTagsWithMarkers')); $stub = $this->getMockBuilder('ShortcodeParser')
->setMethods(array('replaceElementTagsWithMarkers'))
->getMock();
$stub->register('test', function() { $stub->register('test', function() {
return ''; return '';
}); });

View File

@ -138,7 +138,9 @@ class SSViewerTest extends SapphireTest {
} }
public function testRequirements() { public function testRequirements() {
$requirements = $this->getMock("Requirements_Backend", array("javascript", "css")); $requirements = $this->getMockBuilder("Requirements_Backend")
->setMethods(array("javascript", "css"))
->getMock();
$jsFile = FRAMEWORK_DIR . '/tests/forms/a.js'; $jsFile = FRAMEWORK_DIR . '/tests/forms/a.js';
$cssFile = FRAMEWORK_DIR . '/tests/forms/a.js'; $cssFile = FRAMEWORK_DIR . '/tests/forms/a.js';