From 34d524c09fea6e6cf653f335df032ff21862495a Mon Sep 17 00:00:00 2001 From: ajshort Date: Wed, 27 Feb 2013 00:38:40 +1100 Subject: [PATCH 1/3] Integrate composer in the Travis build process Creates a package definition from the framework version being built, and uses composer to install it into an installer project, as well as the required modules for testing. --- .travis.yml | 2 +- tests/travis/before.php | 83 ++++++++++++++++++++++++++++++++++++++ tests/travis/before_script | 34 ---------------- 3 files changed, 84 insertions(+), 35 deletions(-) create mode 100755 tests/travis/before.php delete mode 100755 tests/travis/before_script diff --git a/.travis.yml b/.travis.yml index 567178d0f..f1be2c04b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ matrix: before_script: - pear install pear/PHP_CodeSniffer - phpenv rehash - - ./tests/travis/before_script ~/builds/ss + - ./tests/travis/before.php --target ~/builds/ss --version="2.5.x-dev" --installer="post-2.4" - cd ~/builds/ss script: diff --git a/tests/travis/before.php b/tests/travis/before.php new file mode 100755 index 000000000..41427f2ea --- /dev/null +++ b/tests/travis/before.php @@ -0,0 +1,83 @@ +#!/usr/bin/env php + $version, + 'dist' => array( + 'type' => 'tar', + 'url' => "file://$parent/framework.tar" + ) +); + +// Generate a custom composer file. +$composer = json_encode(array( + 'repositories' => array(array('type' => 'package', 'package' => $package)), + 'require' => array( + 'silverstripe/framework' => $version, + 'silverstripe/postgresql' => '*', + 'silverstripe/sqlite3' => '*' + ), + 'minimum-stability' => 'dev' +)); + +echo "Generated composer file:\n"; +echo "$composer\n\n"; + +echo "Archiving framework...\n"; +`cd $framework`; +`tar -cf $parent/framework.tar .`; + +echo "Cloning installer@$installer...\n"; +`git clone --depth=100 --quiet -b $installer git://github.com/silverstripe/silverstripe-installer.git $target`; + +echo "Setting up project...\n"; +`cp $dir/_ss_environment.php $target`; +`cp $dir/_config.php $target/mysite`; + +echo "Replacing composer file...\n"; +unlink("$target/composer.json"); +file_put_contents("$target/composer.json", $composer); + +echo "Running composer...\n"; +`composer install --dev -d $target`; diff --git a/tests/travis/before_script b/tests/travis/before_script deleted file mode 100755 index adcdc0465..000000000 --- a/tests/travis/before_script +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -### USAGE: before_script - -BUILD_DIR=$1 - -# Environment info -echo "# Environment info" -echo " - `php --version`" -echo " - `mysql --version`" -echo " - `pg_config --version`" -echo " - SQLite3 `sqlite3 -version`" -echo "" - -# Fetch all dependencies -# TODO Replace with different composer.json variations - -echo "Checking out installer@$TRAVIS_BRANCH" -git clone --depth=100 --quiet -b $TRAVIS_BRANCH git://github.com/silverstripe/silverstripe-installer.git $BUILD_DIR - -echo "Checking out sqlite3@master" -git clone --depth=100 --quiet git://github.com/silverstripe-labs/silverstripe-sqlite3.git $BUILD_DIR/sqlite3 - -echo "Checking out postgresql@master" -git clone --depth=100 --quiet git://github.com/silverstripe/silverstripe-postgresql.git $BUILD_DIR/postgresql - -# Copy setup files -cp ./tests/travis/_ss_environment.php $BUILD_DIR -cp ./tests/travis/_config.php $BUILD_DIR/mysite - -# Copy actual project code into build directory (checked out by travis) -cp -r . $BUILD_DIR/framework - -cd $BUILD_DIR From 65b463607e6be30188eecefce1341ce9bbeb2e58 Mon Sep 17 00:00:00 2001 From: ajshort Date: Wed, 27 Feb 2013 00:40:32 +1100 Subject: [PATCH 2/3] Update versions used in the Travis build. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f1be2c04b..bf1069611 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ matrix: before_script: - pear install pear/PHP_CodeSniffer - phpenv rehash - - ./tests/travis/before.php --target ~/builds/ss --version="2.5.x-dev" --installer="post-2.4" + - ./tests/travis/before.php --target ~/builds/ss --version="3.0.x-dev" --installer="3.0" - cd ~/builds/ss script: From e6fffb9ef910979eeef3a881744ecae8480bd164 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 27 Feb 2013 10:06:50 +0100 Subject: [PATCH 3/3] API Remove content-length setting in HTTPResponse It's not reliable. Started in c69381c33, but only partially reverted. --- control/HTTPResponse.php | 4 ---- tests/control/HTTPResponseTest.php | 17 ----------------- 2 files changed, 21 deletions(-) diff --git a/control/HTTPResponse.php b/control/HTTPResponse.php index b45c72653..e7482bb09 100644 --- a/control/HTTPResponse.php +++ b/control/HTTPResponse.php @@ -150,10 +150,6 @@ class SS_HTTPResponse { public function setBody($body) { $this->body = $body; - - // Set content-length in bytes. Use mbstring to avoid problems with - // mb_internal_encoding() and mbstring.func_overload - $this->headers['Content-Length'] = mb_strlen($this->body,'8bit'); } public function getBody() { diff --git a/tests/control/HTTPResponseTest.php b/tests/control/HTTPResponseTest.php index f2f37c693..8b8d38b98 100644 --- a/tests/control/HTTPResponseTest.php +++ b/tests/control/HTTPResponseTest.php @@ -13,21 +13,4 @@ class HTTPResponseTest extends SapphireTest { ); } - public function testContentLengthHeader() { - $r = new SS_HTTPResponse('123ü'); - $this->assertNotNull($r->getHeader('Content-Length'), 'Content-length header is added'); - $this->assertEquals( - 5, - $r->getHeader('Content-Length'), - 'Header matches actual content length in bytes' - ); - - $r->setBody('1234ü'); - $this->assertEquals( - 6, - $r->getHeader('Content-Length'), - 'Header is updated when body is changed' - ); - } - }