diff --git a/.travis.yml b/.travis.yml index b2721b38b..b42b4e492 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ addons: apt: packages: - tidy + firefox: "31.0" matrix: include: @@ -32,8 +33,8 @@ matrix: before_script: - 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" | pecl install imagick-3.3.0; 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" | travis_retry pecl install imagick-3.3.0; fi - composer self-update || true - phpenv rehash - phpenv config-rm xdebug.ini diff --git a/_config/database.yml b/_config/database.yml index 2bb8e1c85..313ea3113 100644 --- a/_config/database.yml +++ b/_config/database.yml @@ -22,5 +22,13 @@ Injector: type: prototype Int: class: DBInt + int: + class: DBInt + INT: + class: DBInt Float: class: DBFloat + float: + class: DBFloat + FLOAT: + class: DBFloat diff --git a/composer.json b/composer.json index c0ca61c8a..794e8d4db 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "mustangostang/spyc": "^0.6.2" }, "require-dev": { - "phpunit/PHPUnit": "~3.7" + "phpunit/phpunit": "^3 || ^4 || ^5" }, "extra": { "branch-alias": { diff --git a/control/Director.php b/control/Director.php index 46565d7b5..1e8fd439b 100644 --- a/control/Director.php +++ b/control/Director.php @@ -810,9 +810,13 @@ class Director implements TemplateGlobalProvider { /** * 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) { + if (static::is_cli()) { + return $destURL; + } $response = new SS_HTTPResponse(); $response->redirect($destURL, 301); @@ -859,9 +863,6 @@ class Director implements TemplateGlobalProvider { $matched = false; if($patterns) { - // Calling from the command-line? - if(!isset($_SERVER['REQUEST_URI'])) return; - $relativeURL = self::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI'])); // 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)); - // This coupling to SapphireTest is necessary to test the destination URL and to not interfere with tests - if(class_exists('SapphireTest', false) && SapphireTest::is_running_test()) { - return $destURL; - } else { - self::force_redirect($destURL); - } + return self::force_redirect($destURL); } else { return false; } diff --git a/control/HTTP.php b/control/HTTP.php index 3b9cdf2e5..1f0d088c6 100644 --- a/control/HTTP.php +++ b/control/HTTP.php @@ -271,7 +271,7 @@ class HTTP { // Fallback to use the list from the HTTP.yml configuration and rely on the file extension // to get the file mime-type - $ext = File::get_file_extension($filename); + $ext = strtolower(File::get_file_extension($filename)); // Get the mime-types $mimeTypes = Config::inst()->get('HTTP', 'MimeTypes'); diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index 87962d462..41ac49f49 100644 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -93,13 +93,14 @@ class HtmlEditorField extends TextareaField { $img->setAttribute('src', preg_replace('/([^\?]*)\?r=[0-9]+$/i', '$1', $img->getAttribute('src'))); // 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'); $height = (int)$img->getAttribute('height'); if($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) { //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()); } } diff --git a/javascript/TreeDropdownField.js b/javascript/TreeDropdownField.js index 782f697e0..32453695e 100644 --- a/javascript/TreeDropdownField.js +++ b/javascript/TreeDropdownField.js @@ -47,7 +47,7 @@ // XMLHttpRequest CurrentXhr: null, - onadd: function() { + onmatch: function() { this.append( '' + '' + @@ -334,7 +334,7 @@ }); $('.TreeDropdownField.searchable').entwine({ - onadd: function() { + onmatch: function() { this._super(); var title = ss.i18n._t('TreeDropdownField.ENTERTOSEARCH'); this.find('.treedropdownfield-panel').prepend( @@ -431,13 +431,13 @@ }); $('.TreeDropdownField input[type=hidden]').entwine({ - onadd: function() { + onmatch: function() { this._super(); this.bind('change.TreeDropdownField', function() { $(this).getField().updateTitle(); }); }, - onremove: function() { + onunmatch: function() { this._super(); this.unbind('.TreeDropdownField'); } diff --git a/model/DataQuery.php b/model/DataQuery.php index c11d33d46..0a720cd64 100644 --- a/model/DataQuery.php +++ b/model/DataQuery.php @@ -755,7 +755,7 @@ class DataQuery { list($parentClass, $componentClass, $parentField, $componentField, $relationTable) = $component; $parentBaseClass = ClassInfo::baseDataClass($parentClass); $componentBaseClass = ClassInfo::baseDataClass($componentClass); - $this->query->addInnerJoin($relationTable, + $this->query->addLeftJoin($relationTable, "\"$relationTable\".\"$parentField\" = \"$parentBaseClass\".\"ID\""); if (!$this->query->isJoinedTo($componentBaseClass)) { $this->query->addLeftJoin($componentBaseClass, diff --git a/model/Versioned.php b/model/Versioned.php index 4dc191628..6c976007f 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -1100,7 +1100,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider { $fromRecord = Versioned::get_version($this->owner->class, $this->owner->ID, $from); $toRecord = Versioned::get_version($this->owner->class, $this->owner->ID, $to); - $diff = new DataDifferencer($fromRecord, $toRecord); + $diff = DataDifferencer::create($fromRecord, $toRecord); return $diff->diffedData(); } diff --git a/tests/control/HTTPTest.php b/tests/control/HTTPTest.php index d15bc3655..b208f44ae 100644 --- a/tests/control/HTTPTest.php +++ b/tests/control/HTTPTest.php @@ -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('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/upperfile.JPG')); $this->assertEquals('image/png', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.png')); $this->assertEquals('image/vnd.adobe.photoshop', HTTP::get_mime_type(FRAMEWORK_DIR.'/tests/control/files/file.psd')); diff --git a/tests/control/files/upperfile.JPG b/tests/control/files/upperfile.JPG new file mode 100644 index 000000000..3aad05d8f Binary files /dev/null and b/tests/control/files/upperfile.JPG differ diff --git a/tests/core/manifest/ConfigManifestTest.php b/tests/core/manifest/ConfigManifestTest.php index 5b14df254..337894101 100644 --- a/tests/core/manifest/ConfigManifestTest.php +++ b/tests/core/manifest/ConfigManifestTest.php @@ -30,13 +30,10 @@ class ConfigManifestTest extends SapphireTest { * @return Zend_Cache_Core */ protected function getCacheMock() { - return $this->getMock( - 'Zend_Cache_Core', - array('load', 'save'), - array(), - '', - false - ); + return $this->getMockBuilder('Zend_Cache_Core') + ->setMethods(array('load', 'save')) + ->disableOriginalConstructor() + ->getMock(); } /** @@ -45,13 +42,10 @@ class ConfigManifestTest extends SapphireTest { * @return SS_ConfigManifest */ protected function getManifestMock($methods) { - return $this->getMock( - 'SS_ConfigManifest', - $methods, - array(), // no constructor arguments - '', // default - false // don't call the constructor - ); + return $this->getMockBuilder('SS_ConfigManifest') + ->setMethods($methods) + ->disableOriginalConstructor() + ->getMock(); } /** diff --git a/tests/injector/InjectorTest.php b/tests/injector/InjectorTest.php index de7173523..2fb577ef8 100644 --- a/tests/injector/InjectorTest.php +++ b/tests/injector/InjectorTest.php @@ -605,7 +605,7 @@ class InjectorTest extends SapphireTest { '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 ->expects($this->once()) ->method('create') diff --git a/tests/model/DataListTest.php b/tests/model/DataListTest.php index ffcc94d63..945c172d5 100755 --- a/tests/model/DataListTest.php +++ b/tests/model/DataListTest.php @@ -774,6 +774,15 @@ class DataListTest extends SapphireTest { $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() { $list = DataObjectTest_TeamComment::get(); $list = $list->filterAny(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob')); diff --git a/tests/model/PaginatedListTest.php b/tests/model/PaginatedListTest.php index 73dc5f879..3447467cc 100644 --- a/tests/model/PaginatedListTest.php +++ b/tests/model/PaginatedListTest.php @@ -43,7 +43,7 @@ class PaginatedListTest extends SapphireTest { } public function testSetPaginationFromQuery() { - $query = $this->getMock('SQLQuery'); + $query = $this->getMockBuilder('SQLQuery')->getMock(); $query->expects($this->once()) ->method('getLimit') ->will($this->returnValue(array('limit' => 15, 'start' => 30))); diff --git a/tests/parsers/ShortcodeParserTest.php b/tests/parsers/ShortcodeParserTest.php index a04c31bd3..f923e6727 100644 --- a/tests/parsers/ShortcodeParserTest.php +++ b/tests/parsers/ShortcodeParserTest.php @@ -277,7 +277,9 @@ class ShortcodeParserTest extends SapphireTest { } public function testNoParseAttemptIfNoCode() { - $stub = $this->getMock('ShortcodeParser', array('replaceElementTagsWithMarkers')); + $stub = $this->getMockBuilder('ShortcodeParser') + ->setMethods(array('replaceElementTagsWithMarkers')) + ->getMock(); $stub->register('test', function() { return ''; }); diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index 62cd678bc..e3db03415 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -138,7 +138,9 @@ class SSViewerTest extends SapphireTest { } 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'; $cssFile = FRAMEWORK_DIR . '/tests/forms/a.js';