mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts: tests/control/HTTPResponseTest.php tests/travis/before_script
This commit is contained in:
commit
39789529d7
@ -26,7 +26,7 @@ matrix:
|
|||||||
before_script:
|
before_script:
|
||||||
- pear install pear/PHP_CodeSniffer
|
- pear install pear/PHP_CodeSniffer
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
- ./tests/travis/before_script ~/builds/ss
|
- ./tests/travis/before.php --target ~/builds/ss --version="3.0.x-dev" --installer="3.0"
|
||||||
- cd ~/builds/ss
|
- cd ~/builds/ss
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
@ -160,10 +160,6 @@ class SS_HTTPResponse {
|
|||||||
*/
|
*/
|
||||||
public function setBody($body) {
|
public function setBody($body) {
|
||||||
$this->body = $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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,23 +13,6 @@ 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'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHTTPResponseException() {
|
public function testHTTPResponseException() {
|
||||||
$response = new SS_HTTPResponse("Test", 200, 'OK');
|
$response = new SS_HTTPResponse("Test", 200, 'OK');
|
||||||
|
|
||||||
|
83
tests/travis/before.php
Executable file
83
tests/travis/before.php
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Initialises a test project that can be built by travis.
|
||||||
|
*
|
||||||
|
* The local framework checkout's composer file is parsed and used to built a
|
||||||
|
* custom local framework archive which is then installed into an installer
|
||||||
|
* base project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (php_sapi_name() != 'cli') {
|
||||||
|
header('HTTP/1.0 404 Not Found');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$opts = getopt('', array(
|
||||||
|
'target:',
|
||||||
|
'version:',
|
||||||
|
'installer:'
|
||||||
|
));
|
||||||
|
|
||||||
|
if (!$opts) {
|
||||||
|
echo "Invalid arguments specified\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
extract($opts);
|
||||||
|
|
||||||
|
$dir = __DIR__;
|
||||||
|
$framework = dirname(dirname($dir));
|
||||||
|
$parent = dirname($framework);
|
||||||
|
|
||||||
|
// Print out some environment information.
|
||||||
|
printf("Database versions:\n");
|
||||||
|
printf(" * MySQL: %s\n", trim(`mysql --version`));
|
||||||
|
printf(" * PostgreSQL: %s\n", trim(`pg_config --version`));
|
||||||
|
printf(" * SQLite: %s\n\n", trim(`sqlite3 -version`));
|
||||||
|
|
||||||
|
// Extract the package info from the framework composer file, and build a
|
||||||
|
// custom project composer file with the local package explicitly defined.
|
||||||
|
echo "Reading composer information...\n";
|
||||||
|
$package = json_decode(file_get_contents("$framework/composer.json"), true);
|
||||||
|
|
||||||
|
// Override the default framework requirement with the one being built.
|
||||||
|
$package += array(
|
||||||
|
'version' => $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`;
|
@ -1,34 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
### USAGE: before_script <base-folder> <travis-branch>
|
|
||||||
|
|
||||||
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@3.1"
|
|
||||||
git clone --depth=100 --quiet -b 3.1 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
|
|
Loading…
x
Reference in New Issue
Block a user