Merge branch '3.1'

Conflicts:
	view/SSViewer.php
This commit is contained in:
Simon Welsh 2014-03-30 19:39:18 +13:00
commit 2566795b59
16 changed files with 97 additions and 72 deletions

View File

@ -108,7 +108,8 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider {
*
* @return boolean Success
*/
public static function add_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1, $attributes = null) {
public static function add_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1,
$attributes = null) {
// If a class is defined, then force the use of that as a code. This helps prevent menu item duplication
if($controllerClass) {
$code = $controllerClass;
@ -238,7 +239,8 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider {
*
* @return boolean Success
*/
public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1, $attributes = null) {
public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1,
$attributes = null) {
$item = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority);
if($attributes) {

View File

@ -241,7 +241,9 @@ class SS_HTTPResponse {
"<p>Redirecting to <a href=\"$urlATT\" title=\"Click this link if your browser does not redirect you\">"
. "$urlATT... (output started on $file, line $line)</a></p>
<meta http-equiv=\"refresh\" content=\"1; url=$urlATT\" />
<script type=\"text/javascript\">setTimeout(function(){ window.location.href = \"$urlJS\"; }, 50);</script>";
<script type=\"text/javascript\">setTimeout(function(){
window.location.href = \"$urlJS\";
}, 50);</script>";
} else {
$line = $file = null;
if(!headers_sent($file, $line)) {

View File

@ -471,8 +471,10 @@ abstract class Object {
/**
* Return TRUE if a class has a specified extension.
* This supports backwards-compatible format (static Object::has_extension($requiredExtension)) and new format ($object->has_extension($class, $requiredExtension))
* @param string $classOrExtension if 1 argument supplied, the class name of the extension to check for; if 2 supplied, the class name to test
* This supports backwards-compatible format (static Object::has_extension($requiredExtension))
* and new format ($object->has_extension($class, $requiredExtension))
* @param string $classOrExtension if 1 argument supplied, the class name of the extension to
* check for; if 2 supplied, the class name to test
* @param string $requiredExtension used only if 2 arguments supplied
*/
public static function has_extension($classOrExtension, $requiredExtension = null) {

View File

@ -300,17 +300,17 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
}
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
/**
* Trys to get the original exception thrown by the test on failure/error

View File

@ -47,15 +47,15 @@ class SilverStripeListener implements PHPUnit_Framework_TestListener {
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
}

View File

@ -62,15 +62,15 @@ class TeamCityListener implements PHPUnit_Framework_TestListener {
echo "##teamcity[testIgnored name='{$class}.{$test->getName()}' message='$message']\n";
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
}

View File

@ -38,17 +38,17 @@ class SS_TestListener implements PHPUnit_Framework_TestListener {
$this->class->tearDownOnce();
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
// Stub out to support PHPUnit 3.8
}
/**
* @param String Classname

View File

@ -16,8 +16,8 @@ class GroupedList extends SS_ListDecorator {
$result = array();
foreach ($this->list as $item) {
/* if $item is an Object, $index can be a method or a value,
* if $item is an array, $index is used as the index */
// if $item is an Object, $index can be a method or a value,
// if $item is an array, $index is used as the index
$key = is_object($item) ? ($item->hasMethod($index) ? $item->$index() : $item->$index) : $item[$index];
if (array_key_exists($key, $result)) {

View File

@ -131,7 +131,8 @@ class CmsFormsContext extends BehatContext {
*
* @todo Use an actual DOM parser for more accurate assertions
*
* @Given /^"(?P<text>([^"]*))" in the "(?P<field>([^"]*))" HTML field should(?P<negate>(?: not)?) be (?P<formatting>(.*))$/
* @Given /^"(?P<text>([^"]*))" in the "(?P<field>([^"]*))" HTML field
* should(?P<negate>(?: not)?) be (?P<formatting>(.*))$/
*/
public function stepContentInHtmlFieldShouldHaveFormatting($text, $field, $negate, $formatting) {
$page = $this->getSession()->getPage();

View File

@ -238,7 +238,8 @@ class ControllerTest extends FunctionalTest {
Controller::join_links("?a=1", "admin/crm", "?b=2", "MyForm?c=3"));
// And duplicates are handled nicely
$this->assertEquals("admin/crm?foo=2&bar=3&baz=1", Controller::join_links("admin/crm?foo=1&bar=1&baz=1", "?foo=2&bar=3"));
$this->assertEquals("admin/crm?foo=2&bar=3&baz=1",
Controller::join_links("admin/crm?foo=1&bar=1&baz=1", "?foo=2&bar=3"));
$this->assertEquals (
'admin/action', Controller::join_links('admin/', '/', '/action'), 'Test that multiple slashes are trimmed.'

View File

@ -358,9 +358,12 @@ class RequirementsTest extends SapphireTest {
$template = '<html><head></head><body><header>My header</header><p>Body<script></script></p></body></html>';
// The expected outputs
$JsInHead = "<html><head><script type=\"text/javascript\" src=\"http://www.mydomain.com/test.js\"></script>\n</head><body><header>My header</header><p>Body<script></script></p></body></html>";
$JsInBody = "<html><head></head><body><header>My header</header><p>Body<script type=\"text/javascript\" src=\"http://www.mydomain.com/test.js\"></script><script></script></p></body></html>";
$JsAtEnd = "<html><head></head><body><header>My header</header><p>Body<script></script></p><script type=\"text/javascript\" src=\"http://www.mydomain.com/test.js\"></script></body></html>";
$JsInHead = "<html><head><script type=\"text/javascript\" src=\"http://www.mydomain.com/test.js\">"
. "</script>\n</head><body><header>My header</header><p>Body<script></script></p></body></html>";
$JsInBody = "<html><head></head><body><header>My header</header><p>Body<script type=\"text/javascript\""
. " src=\"http://www.mydomain.com/test.js\"></script><script></script></p></body></html>";
$JsAtEnd = "<html><head></head><body><header>My header</header><p>Body<script></script></p><script "
. "type=\"text/javascript\" src=\"http://www.mydomain.com/test.js\"></script></body></html>";
// Test if the script is before the head tag, not before the body.

View File

@ -30,11 +30,15 @@ class GridFieldSortableHeaderTest extends SapphireTest {
// Check that the output shows name and hat as sortable fields, but not city
$this->assertContains('<span class="non-sortable">City</span>', $htmlFragment['header']);
$this->assertContains('value="Name" class="action ss-gridfield-sort" id="action_SetOrderName"', $htmlFragment['header']);
$this->assertContains('value="Cheerleader Hat" class="action ss-gridfield-sort" id="action_SetOrderCheerleader-Hat-Colour"', $htmlFragment['header']);
$this->assertContains('value="Name" class="action ss-gridfield-sort" id="action_SetOrderName"',
$htmlFragment['header']);
$this->assertContains(
'value="Cheerleader Hat" class="action ss-gridfield-sort" id="action_SetOrderCheerleader-Hat-Colour"',
$htmlFragment['header']);
// Check inverse of above
$this->assertNotContains('value="City" class="action ss-gridfield-sort" id="action_SetOrderCity"', $htmlFragment['header']);
$this->assertNotContains('value="City" class="action ss-gridfield-sort" id="action_SetOrderCity"',
$htmlFragment['header']);
$this->assertNotContains('<span class="non-sortable">Name</span>', $htmlFragment['header']);
$this->assertNotContains('<span class="non-sortable">Cheerleader Hat</span>', $htmlFragment['header']);
}

View File

@ -24,7 +24,7 @@ class SSViewerCacheBlockTest_VersionedModel extends DataObject implements TestOn
protected $entropy = 'default';
public static $extensions = array(
private static $extensions = array(
"Versioned('Stage', 'Live')"
);

View File

@ -2946,10 +2946,10 @@ class SSTemplateParser extends Parser implements TemplateParser {
// Embed the code necessary to evaluate the globalKey directly into the template,
// so that SSTemplateParser only needs to be called during template regeneration.
// Warning: If the global key is changed, it's necessary to flush the template cache.
$parser = new SSTemplateParser($globalKey);
$result = $parser->match_Template();
$parser = Injector::inst()->get('SSTemplateParser', false);
$result = $parser->compileString($globalKey, '', false, false);
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $parser);
$res['php'] .= $result['php'] . PHP_EOL;
$res['php'] .= $result . PHP_EOL;
}
$res['php'] .= 'return $val;' . PHP_EOL;
$res['php'] .= '};' . PHP_EOL;
@ -4703,9 +4703,10 @@ class SSTemplateParser extends Parser implements TemplateParser {
* @param $string The source of the template
* @param string $templateName The name of the template, normally the filename the template source was loaded from
* @param bool $includeDebuggingComments True is debugging comments should be included in the output
* @param bool $topTemplate True if this is a top template, false if it's just a template
* @return mixed|string The php that, when executed (via include or exec) will behave as per the template source
*/
public function compileString($string, $templateName = "", $includeDebuggingComments=false) {
public function compileString($string, $templateName = "", $includeDebuggingComments=false, $topTemplate = true) {
if (!trim($string)) {
$code = '';
}
@ -4719,7 +4720,11 @@ class SSTemplateParser extends Parser implements TemplateParser {
if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3;
// Match the source against the parser
$result = $this->match_TopTemplate();
if ($topTemplate) {
$result = $this->match_TopTemplate();
} else {
$result = $this->match_Template();
}
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this);
// Get the result

View File

@ -681,10 +681,10 @@ class SSTemplateParser extends Parser implements TemplateParser {
// Embed the code necessary to evaluate the globalKey directly into the template,
// so that SSTemplateParser only needs to be called during template regeneration.
// Warning: If the global key is changed, it's necessary to flush the template cache.
$parser = new SSTemplateParser($globalKey);
$result = $parser->match_Template();
$parser = Injector::inst()->get('SSTemplateParser', false);
$result = $parser->compileString($globalKey, '', false, false);
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $parser);
$res['php'] .= $result['php'] . PHP_EOL;
$res['php'] .= $result . PHP_EOL;
}
$res['php'] .= 'return $val;' . PHP_EOL;
$res['php'] .= '};' . PHP_EOL;
@ -1157,9 +1157,10 @@ class SSTemplateParser extends Parser implements TemplateParser {
* @param $string The source of the template
* @param string $templateName The name of the template, normally the filename the template source was loaded from
* @param bool $includeDebuggingComments True is debugging comments should be included in the output
* @param bool $topTemplate True if this is a top template, false if it's just a template
* @return mixed|string The php that, when executed (via include or exec) will behave as per the template source
*/
public function compileString($string, $templateName = "", $includeDebuggingComments=false) {
public function compileString($string, $templateName = "", $includeDebuggingComments=false, $topTemplate = true) {
if (!trim($string)) {
$code = '';
}
@ -1173,7 +1174,11 @@ class SSTemplateParser extends Parser implements TemplateParser {
if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3;
// Match the source against the parser
$result = $this->match_TopTemplate();
if ($topTemplate) {
$result = $this->match_TopTemplate();
} else {
$result = $this->match_Template();
}
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this);
// Get the result

View File

@ -755,7 +755,7 @@ class SSViewer {
* </code>
*/
public function __construct($templateList, TemplateParser $parser = null) {
$this->setParser($parser ?: Injector::inst()->get('SSTemplateParser'));
$this->setParser($parser ?: Injector::inst()->get('SSTemplateParser'));
// flush template manifest cache if requested
if (isset($_GET['flush']) && $_GET['flush'] == 'all') {
@ -1203,7 +1203,7 @@ class SSViewer_FromString extends SSViewer {
protected $cacheTemplate;
public function __construct($content, TemplateParser $parser = null) {
$this->setParser($parser ?: Injector::inst()->get('SSTemplateParser'));
$this->setParser($parser ?: Injector::inst()->get('SSTemplateParser'));
$this->content = $content;
}