mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge remote-tracking branch 'origin/3.0'
This commit is contained in:
commit
15a687f1e7
@ -191,15 +191,14 @@ class FunctionalTest extends SapphireTest {
|
|||||||
if($items) foreach($items as $item) $actuals[trim(preg_replace("/[ \n\r\t]+/", " ", $item. ''))] = true;
|
if($items) foreach($items as $item) $actuals[trim(preg_replace("/[ \n\r\t]+/", " ", $item. ''))] = true;
|
||||||
|
|
||||||
foreach($expectedMatches as $match) {
|
foreach($expectedMatches as $match) {
|
||||||
if(!isset($actuals[$match])) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
isset($actuals[$match]),
|
||||||
"Failed asserting the CSS selector '$selector' has a partial match to the expected elements:\n'"
|
"Failed asserting the CSS selector '$selector' has a partial match to the expected elements:\n'"
|
||||||
. implode("'\n'", $expectedMatches) . "'\n\n"
|
. implode("'\n'", $expectedMatches) . "'\n\n"
|
||||||
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -224,14 +223,12 @@ class FunctionalTest extends SapphireTest {
|
|||||||
$actuals = array();
|
$actuals = array();
|
||||||
if($items) foreach($items as $item) $actuals[] = trim(preg_replace("/[ \n\r\t]+/", " ", $item. ''));
|
if($items) foreach($items as $item) $actuals[] = trim(preg_replace("/[ \n\r\t]+/", " ", $item. ''));
|
||||||
|
|
||||||
if($expectedMatches != $actuals) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
$expectedMatches == $actuals,
|
||||||
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'"
|
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'"
|
||||||
. implode("'\n'", $expectedMatches) . "'\n\n"
|
. implode("'\n'", $expectedMatches) . "'\n\n"
|
||||||
. "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'"
|
. "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'"
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -257,14 +254,12 @@ class FunctionalTest extends SapphireTest {
|
|||||||
if($items) foreach($items as $item) $actuals[$item->asXML()] = true;
|
if($items) foreach($items as $item) $actuals[$item->asXML()] = true;
|
||||||
|
|
||||||
foreach($expectedMatches as $match) {
|
foreach($expectedMatches as $match) {
|
||||||
if(!isset($actuals[$match])) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
isset($actuals[$match]),
|
||||||
"Failed asserting the CSS selector '$selector' has a partial match to the expected elements:\n'"
|
"Failed asserting the CSS selector '$selector' has a partial match to the expected elements:\n'"
|
||||||
. implode("'\n'", $expectedMatches) . "'\n\n"
|
. implode("'\n'", $expectedMatches) . "'\n\n"
|
||||||
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -288,14 +283,13 @@ class FunctionalTest extends SapphireTest {
|
|||||||
$actuals = array();
|
$actuals = array();
|
||||||
if($items) foreach($items as $item) $actuals[] = $item->asXML();
|
if($items) foreach($items as $item) $actuals[] = $item->asXML();
|
||||||
|
|
||||||
if($expectedMatches != $actuals) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
$expectedMatches == $actuals,
|
||||||
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'"
|
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'"
|
||||||
. implode("'\n'", $expectedMatches) . "'\n\n"
|
. implode("'\n'", $expectedMatches) . "'\n\n"
|
||||||
. "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'"
|
. "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log in as the given member
|
* Log in as the given member
|
||||||
|
@ -272,6 +272,8 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
* for tearing down the state again.
|
* for tearing down the state again.
|
||||||
*/
|
*/
|
||||||
public function setUpOnce() {
|
public function setUpOnce() {
|
||||||
|
$isAltered = false;
|
||||||
|
|
||||||
// Remove any illegal extensions that are present
|
// Remove any illegal extensions that are present
|
||||||
foreach($this->illegalExtensions as $class => $extensions) {
|
foreach($this->illegalExtensions as $class => $extensions) {
|
||||||
foreach($extensions as $extension) {
|
foreach($extensions as $extension) {
|
||||||
@ -298,7 +300,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we have made changes to the extensions present, then migrate the database schema.
|
// If we have made changes to the extensions present, then migrate the database schema.
|
||||||
if($this->extensionsToReapply || $this->extensionsToRemove || $this->extraDataObjects) {
|
if($isAltered || $this->extensionsToReapply || $this->extensionsToRemove || $this->extraDataObjects) {
|
||||||
if(!self::using_temp_db()) self::create_temp_db();
|
if(!self::using_temp_db()) self::create_temp_db();
|
||||||
$this->resetDBSchema(true);
|
$this->resetDBSchema(true);
|
||||||
}
|
}
|
||||||
@ -540,8 +542,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
* 'customHeaders', 'htmlContent', inlineImages'
|
* 'customHeaders', 'htmlContent', inlineImages'
|
||||||
*/
|
*/
|
||||||
public function assertEmailSent($to, $from = null, $subject = null, $content = null) {
|
public function assertEmailSent($to, $from = null, $subject = null, $content = null) {
|
||||||
// To do - this needs to be turned into a "real" PHPUnit ass
|
$found = (bool)$this->findEmail($to, $from, $subject, $content);
|
||||||
if(!$this->findEmail($to, $from, $subject, $content)) {
|
|
||||||
|
|
||||||
$infoParts = "";
|
$infoParts = "";
|
||||||
$withParts = array();
|
$withParts = array();
|
||||||
@ -551,11 +552,11 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
if($content) $withParts[] = "content '$content'";
|
if($content) $withParts[] = "content '$content'";
|
||||||
if($withParts) $infoParts .= " with " . implode(" and ", $withParts);
|
if($withParts) $infoParts .= " with " . implode(" and ", $withParts);
|
||||||
|
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
$this->assertTrue(
|
||||||
|
$found,
|
||||||
"Failed asserting that an email was sent$infoParts."
|
"Failed asserting that an email was sent$infoParts."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -594,15 +595,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We couldn't find a match - assertion failed
|
// We couldn't find a match - assertion failed
|
||||||
if(!$matched) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
$matched,
|
||||||
"Failed asserting that the SS_List contains an item matching "
|
"Failed asserting that the SS_List contains an item matching "
|
||||||
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
||||||
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -640,24 +639,22 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We couldn't find a match - assertion failed
|
// We couldn't find a match - assertion failed
|
||||||
if(!$matched) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
$matched,
|
||||||
"Failed asserting that the SS_List contains an item matching "
|
"Failed asserting that the SS_List contains an item matching "
|
||||||
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
||||||
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If we have leftovers than the DOS has extra data that shouldn't be there
|
// If we have leftovers than the DOS has extra data that shouldn't be there
|
||||||
if($extracted) {
|
$this->assertTrue(
|
||||||
|
(count($extracted) == 0),
|
||||||
// If we didn't break by this point then we couldn't find a match
|
// If we didn't break by this point then we couldn't find a match
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
|
||||||
"Failed asserting that the SS_List contained only the given items, the "
|
"Failed asserting that the SS_List contained only the given items, the "
|
||||||
. "following items were left over:\n" . var_export($extracted, true)
|
. "following items were left over:\n" . var_export($extracted, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert that the every record in the given {@link SS_List} matches the given key-value
|
* Assert that the every record in the given {@link SS_List} matches the given key-value
|
||||||
@ -676,14 +673,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
foreach($dataObjectSet as $item) $extracted[] = $item->toMap();
|
foreach($dataObjectSet as $item) $extracted[] = $item->toMap();
|
||||||
|
|
||||||
foreach($extracted as $i => $item) {
|
foreach($extracted as $i => $item) {
|
||||||
if(!$this->dataObjectArrayMatch($item, $match)) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
$this->dataObjectArrayMatch($item, $match),
|
||||||
"Failed asserting that the the following item matched "
|
"Failed asserting that the the following item matched "
|
||||||
. var_export($match, true) . ": " . var_export($item, true)
|
. var_export($match, true) . ": " . var_export($item, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function for the DOS matchers
|
* Helper function for the DOS matchers
|
||||||
@ -799,6 +795,8 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
*/
|
*/
|
||||||
public function resetDBSchema($includeExtraDataObjects = false) {
|
public function resetDBSchema($includeExtraDataObjects = false) {
|
||||||
if(self::using_temp_db()) {
|
if(self::using_temp_db()) {
|
||||||
|
DataObject::reset();
|
||||||
|
|
||||||
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
||||||
Injector::inst()->unregisterAllObjects();
|
Injector::inst()->unregisterAllObjects();
|
||||||
|
|
||||||
|
@ -1245,7 +1245,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deleting a record without an ID shouldn't do anything
|
// Deleting a record without an ID shouldn't do anything
|
||||||
if(!$this->ID) throw new Exception("DataObject::delete() called on a DataObject without an ID");
|
if(!$this->ID) throw new LogicException("DataObject::delete() called on a DataObject without an ID");
|
||||||
|
|
||||||
// TODO: This is quite ugly. To improve:
|
// TODO: This is quite ugly. To improve:
|
||||||
// - move the details of the delete code in the DataQuery system
|
// - move the details of the delete code in the DataQuery system
|
||||||
|
@ -26,7 +26,7 @@ class RequestHandlingTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testRequestHandlerChainingAllParams() {
|
public function testRequestHandlerChainingAllParams() {
|
||||||
// TODO
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMethodCallingOnController() {
|
public function testMethodCallingOnController() {
|
||||||
|
@ -161,7 +161,7 @@ class ConfigTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testFragmentOrder() {
|
public function testFragmentOrder() {
|
||||||
// $manifest = new SS_ConfigManifest(BASE_PATH, false, true);
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -296,6 +296,7 @@ class ObjectTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testCacheToFile() {
|
public function testCacheToFile() {
|
||||||
|
$this->markTestIncomplete();
|
||||||
/*
|
/*
|
||||||
// This doesn't run properly on our build slave.
|
// This doesn't run properly on our build slave.
|
||||||
$obj = new ObjectTest_CacheTest();
|
$obj = new ObjectTest_CacheTest();
|
||||||
|
@ -25,7 +25,7 @@ class DeprecationTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testLesserVersionTriggersNoNotice() {
|
public function testLesserVersionTriggersNoNotice() {
|
||||||
Deprecation::notification_version('1.0.0');
|
Deprecation::notification_version('1.0.0');
|
||||||
Deprecation::notice('2.0', 'Deprecation test failed');
|
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test failed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,8 +38,8 @@ class DeprecationTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenum() {
|
public function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenum() {
|
||||||
Deprecation::notification_version('2.0.0-beta1');
|
Deprecation::notification_version('2.0.0-beta1');
|
||||||
Deprecation::notice('2.0', 'Deprecation test failed');
|
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test failed'));
|
||||||
Deprecation::notice('2.0.0', 'Deprecation test failed');
|
$this->assertNull(Deprecation::notice('2.0.0', 'Deprecation test failed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +99,7 @@ class DeprecationTest extends SapphireTest {
|
|||||||
|
|
||||||
protected function callThatOriginatesFromFramework() {
|
protected function callThatOriginatesFromFramework() {
|
||||||
$this->assertEquals(DeprecationTest_Deprecation::get_module(), FRAMEWORK_DIR);
|
$this->assertEquals(DeprecationTest_Deprecation::get_module(), FRAMEWORK_DIR);
|
||||||
Deprecation::notice('2.0', 'Deprecation test passed');
|
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test passed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,8 @@ class FileTest extends SapphireTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see http://open.silverstripe.org/ticket/5693
|
* @see http://open.silverstripe.org/ticket/5693
|
||||||
|
*
|
||||||
|
* @expectedException ValidationException
|
||||||
*/
|
*/
|
||||||
public function testSetNameWithInvalidExtensionDoesntChangeFilesystem() {
|
public function testSetNameWithInvalidExtensionDoesntChangeFilesystem() {
|
||||||
$origExts = File::$allowed_extensions;
|
$origExts = File::$allowed_extensions;
|
||||||
@ -177,11 +179,8 @@ class FileTest extends SapphireTest {
|
|||||||
$file->write();
|
$file->write();
|
||||||
} catch(ValidationException $e) {
|
} catch(ValidationException $e) {
|
||||||
File::$allowed_extensions = $origExts;
|
File::$allowed_extensions = $origExts;
|
||||||
return;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fail('Expected ValidationException not raised');
|
|
||||||
File::$allowed_extensions = $origExts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLinkAndRelativeLink() {
|
public function testLinkAndRelativeLink() {
|
||||||
|
@ -30,9 +30,8 @@ class EmailFieldTest extends FunctionalTest {
|
|||||||
$val = new EmailFieldTest_Validator();
|
$val = new EmailFieldTest_Validator();
|
||||||
try {
|
try {
|
||||||
$field->validate($val);
|
$field->validate($val);
|
||||||
if (!$expectSuccess) {
|
// If we expect failure and processing gets here without an exception, the test failed
|
||||||
$this->assertTrue(false,$checkText . " (/$email/ passed validation, but not expected to)");
|
$this->assertTrue($expectSuccess,$checkText . " (/$email/ passed validation, but not expected to)");
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($e instanceof PHPUnit_Framework_AssertionFailedError) throw $e; // re-throw assertion failure
|
if ($e instanceof PHPUnit_Framework_AssertionFailedError) throw $e; // re-throw assertion failure
|
||||||
else if ($expectSuccess) {
|
else if ($expectSuccess) {
|
||||||
|
@ -273,13 +273,15 @@ class GridFieldTest extends SapphireTest {
|
|||||||
* @covers GridField::gridFieldAlterAction
|
* @covers GridField::gridFieldAlterAction
|
||||||
*/
|
*/
|
||||||
public function testGridFieldAlterAction() {
|
public function testGridFieldAlterAction() {
|
||||||
$config = GridFieldConfig::create()->addComponent(new GridFieldTest_Component);
|
$this->markTestIncomplete();
|
||||||
$obj = new GridField('testfield', 'testfield', ArrayList::create(), $config);
|
|
||||||
$id = 'testGridStateActionField';
|
// $config = GridFieldConfig::create()->addComponent(new GridFieldTest_Component);
|
||||||
Session::set($id, array('grid'=>'', 'actionName'=>'jump'));
|
// $obj = new GridField('testfield', 'testfield', ArrayList::create(), $config);
|
||||||
$form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList());
|
// $id = 'testGridStateActionField';
|
||||||
$request = new SS_HTTPRequest('POST', 'url');
|
// Session::set($id, array('grid'=>'', 'actionName'=>'jump'));
|
||||||
$obj->gridFieldAlterAction(array('StateID'=>$id), $form, $request);
|
// $form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList());
|
||||||
|
// $request = new SS_HTTPRequest('POST', 'url');
|
||||||
|
// $obj->gridFieldAlterAction(array('StateID'=>$id), $form, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,29 +281,29 @@ class RequirementsTest extends SapphireTest {
|
|||||||
// to something else
|
// to something else
|
||||||
$basePath = 'framework' . substr($basePath, strlen(FRAMEWORK_DIR));
|
$basePath = 'framework' . substr($basePath, strlen(FRAMEWORK_DIR));
|
||||||
|
|
||||||
$backend = new RequirementsTest_Backend();
|
$backend = new Requirements_Backend();
|
||||||
$holder = Requirements::backend();
|
$holder = Requirements::backend();
|
||||||
Requirements::set_backend($backend);
|
Requirements::set_backend($backend);
|
||||||
$data = new ArrayData(array(
|
$data = new ArrayData(array(
|
||||||
'FailTest' => true,
|
'FailTest' => true,
|
||||||
));
|
));
|
||||||
$data->renderWith('RequirementsTest_Conditionals');
|
$data->renderWith('RequirementsTest_Conditionals');
|
||||||
$backend->assertFileIncluded('css', $basePath .'/RequirementsTest_a.css');
|
$this->assertFileIncluded($backend, 'css', $basePath .'/RequirementsTest_a.css');
|
||||||
$backend->assertFileIncluded('js',
|
$this->assertFileIncluded($backend, 'js',
|
||||||
array($basePath .'/RequirementsTest_b.js', $basePath .'/RequirementsTest_c.js'));
|
array($basePath .'/RequirementsTest_b.js', $basePath .'/RequirementsTest_c.js'));
|
||||||
$backend->assertFileNotIncluded('js', $basePath .'/RequirementsTest_a.js');
|
$this->assertFileNotIncluded($backend, 'js', $basePath .'/RequirementsTest_a.js');
|
||||||
$backend->assertFileNotIncluded('css',
|
$this->assertFileNotIncluded($backend, 'css',
|
||||||
array($basePath .'/RequirementsTest_b.css', $basePath .'/RequirementsTest_c.css'));
|
array($basePath .'/RequirementsTest_b.css', $basePath .'/RequirementsTest_c.css'));
|
||||||
$backend->clear();
|
$backend->clear();
|
||||||
$data = new ArrayData(array(
|
$data = new ArrayData(array(
|
||||||
'FailTest' => false,
|
'FailTest' => false,
|
||||||
));
|
));
|
||||||
$data->renderWith('RequirementsTest_Conditionals');
|
$data->renderWith('RequirementsTest_Conditionals');
|
||||||
$backend->assertFileNotIncluded('css', $basePath .'/RequirementsTest_a.css');
|
$this->assertFileNotIncluded($backend, 'css', $basePath .'/RequirementsTest_a.css');
|
||||||
$backend->assertFileNotIncluded('js',
|
$this->assertFileNotIncluded($backend, 'js',
|
||||||
array($basePath .'/RequirementsTest_b.js', $basePath .'/RequirementsTest_c.js'));
|
array($basePath .'/RequirementsTest_b.js', $basePath .'/RequirementsTest_c.js'));
|
||||||
$backend->assertFileIncluded('js', $basePath .'/RequirementsTest_a.js');
|
$this->assertFileIncluded($backend, 'js', $basePath .'/RequirementsTest_a.js');
|
||||||
$backend->assertFileIncluded('css',
|
$this->assertFileIncluded($backend, 'css',
|
||||||
array($basePath .'/RequirementsTest_b.css', $basePath .'/RequirementsTest_c.css'));
|
array($basePath .'/RequirementsTest_b.css', $basePath .'/RequirementsTest_c.css'));
|
||||||
Requirements::set_backend($holder);
|
Requirements::set_backend($holder);
|
||||||
}
|
}
|
||||||
@ -323,82 +323,93 @@ class RequirementsTest extends SapphireTest {
|
|||||||
$html = $backend->includeInHTML(false, $template);
|
$html = $backend->includeInHTML(false, $template);
|
||||||
$this->assertNotContains('<head><script', $html);
|
$this->assertNotContains('<head><script', $html);
|
||||||
$this->assertContains('</script></body>', $html);
|
$this->assertContains('</script></body>', $html);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class RequirementsTest_Backend extends Requirements_Backend implements TestOnly {
|
public function assertFileIncluded($backend, $type, $files) {
|
||||||
public function assertFileIncluded($type, $files) {
|
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
switch (strtolower($type)) {
|
switch (strtolower($type)) {
|
||||||
case 'css':
|
case 'css':
|
||||||
$var = 'css';
|
$method = 'get_css';
|
||||||
$type = 'CSS';
|
$type = 'CSS';
|
||||||
break;
|
break;
|
||||||
case 'js':
|
case 'js':
|
||||||
case 'javascript':
|
case 'javascript':
|
||||||
case 'script':
|
case 'script':
|
||||||
$var = 'javascript';
|
$method = 'get_javascript';
|
||||||
$type = 'JavaScript';
|
$type = 'JavaScript';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$includedFiles = $backend->$method();
|
||||||
|
|
||||||
|
// Workaround for inconsistent return formats
|
||||||
|
if($method == 'get_javascript') {
|
||||||
|
$includedFiles = array_combine(array_values($includedFiles), array_values($includedFiles));
|
||||||
|
}
|
||||||
|
|
||||||
if(is_array($files)) {
|
if(is_array($files)) {
|
||||||
$failedMatches = array();
|
$failedMatches = array();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if(!array_key_exists($file, $this->$var)) {
|
if(!array_key_exists($file, $includedFiles)) {
|
||||||
$failedMatches[] = $file;
|
$failedMatches[] = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count($failedMatches) > 0) throw new PHPUnit_Framework_AssertionFailedError(
|
$this->assertTrue(
|
||||||
|
(count($failedMatches) == 0),
|
||||||
"Failed asserting the $type files '"
|
"Failed asserting the $type files '"
|
||||||
. implode("', '", $failedMatches)
|
. implode("', '", $failedMatches)
|
||||||
. "' have exact matches in the required elements:\n'"
|
. "' have exact matches in the required elements:\n'"
|
||||||
. implode("'\n'", array_keys($this->$var)) . "'"
|
. implode("'\n'", array_keys($includedFiles)) . "'"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if(!array_key_exists($files, $this->$var)) {
|
$this->assertTrue(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
(array_key_exists($files, $includedFiles)),
|
||||||
"Failed asserting the $type file '$files' has an exact match in the required elements:\n'"
|
"Failed asserting the $type file '$files' has an exact match in the required elements:\n'"
|
||||||
. implode("'\n'", array_keys($this->$var)) . "'"
|
. implode("'\n'", array_keys($includedFiles)) . "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function assertFileNotIncluded($type, $files) {
|
public function assertFileNotIncluded($backend, $type, $files) {
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'css':
|
case 'css':
|
||||||
$var = 'css';
|
$method = 'get_css';
|
||||||
$type = 'CSS';
|
$type = 'CSS';
|
||||||
break;
|
break;
|
||||||
case 'js':
|
case 'js':
|
||||||
case 'javascript':
|
case 'get_javascript':
|
||||||
case 'script':
|
case 'script':
|
||||||
$var = 'javascript';
|
$method = 'get_javascript';
|
||||||
$type = 'JavaScript';
|
$type = 'JavaScript';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$includedFiles = $backend->$method();
|
||||||
|
|
||||||
|
// Workaround for inconsistent return formats
|
||||||
|
if($method == 'get_javascript') {
|
||||||
|
$includedFiles = array_combine(array_values($includedFiles), array_values($includedFiles));
|
||||||
|
}
|
||||||
|
|
||||||
if(is_array($files)) {
|
if(is_array($files)) {
|
||||||
$failedMatches = array();
|
$failedMatches = array();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if(array_key_exists($file, $this->$var)) {
|
if(array_key_exists($file, $includedFiles)) {
|
||||||
$failedMatches[] = $file;
|
$failedMatches[] = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count($failedMatches) > 0) throw new PHPUnit_Framework_AssertionFailedError(
|
$this->assertTrue(
|
||||||
|
(count($failedMatches) == 0),
|
||||||
"Failed asserting the $type files '"
|
"Failed asserting the $type files '"
|
||||||
. implode("', '", $failedMatches)
|
. implode("', '", $failedMatches)
|
||||||
. "' do not have exact matches in the required elements:\n'"
|
. "' do not have exact matches in the required elements:\n'"
|
||||||
. implode("'\n'", array_keys($this->$var)) . "'"
|
. implode("'\n'", array_keys($includedFiles)) . "'"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if(array_key_exists($files, $this->$var)) {
|
$this->assertFalse(
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
(array_key_exists($files, $includedFiles)),
|
||||||
"Failed asserting the $type file '$files' does not have an exact match in the required elements:"
|
"Failed asserting the $type file '$files' does not have an exact match in the required elements:"
|
||||||
. "\n'" . implode("'\n'", array_keys($this->$var)) . "'"
|
. "\n'" . implode("'\n'", array_keys($includedFiles)) . "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -148,7 +148,7 @@ class AggregateTest extends SapphireTest {
|
|||||||
* Test aggregates are cached properly
|
* Test aggregates are cached properly
|
||||||
*/
|
*/
|
||||||
public function testCache() {
|
public function testCache() {
|
||||||
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ class DataListTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testFilter() {
|
public function testFilter() {
|
||||||
// coming soon!
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhere() {
|
public function testWhere() {
|
||||||
|
@ -1021,24 +1021,19 @@ class DataObjectTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException LogicException
|
||||||
|
*/
|
||||||
public function testInvalidate() {
|
public function testInvalidate() {
|
||||||
$do = new DataObjectTest_Fixture();
|
$do = new DataObjectTest_Fixture();
|
||||||
$do->write();
|
$do->write();
|
||||||
|
|
||||||
$do->delete();
|
$do->delete();
|
||||||
|
|
||||||
try {
|
$do->delete(); // Prohibit invalid object manipulation
|
||||||
// Prohibit invalid object manipulation
|
|
||||||
$do->delete();
|
|
||||||
$do->write();
|
$do->write();
|
||||||
$do->duplicate();
|
$do->duplicate();
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->fail('Should throw an exception');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testToMap() {
|
public function testToMap() {
|
||||||
$obj = $this->objFromFixture('DataObjectTest_SubTeam', 'subteam1');
|
$obj = $this->objFromFixture('DataObjectTest_SubTeam', 'subteam1');
|
||||||
|
@ -51,7 +51,11 @@ class DatabaseTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testMySQLCreateTableOptions() {
|
public function testMySQLCreateTableOptions() {
|
||||||
if(DB::getConn() instanceof MySQLDatabase) {
|
if(!(DB::getConn() instanceof MySQLDatabase)) {
|
||||||
|
$this->markTestSkipped('MySQL only');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$ret = DB::query(sprintf(
|
$ret = DB::query(sprintf(
|
||||||
'SHOW TABLE STATUS WHERE "Name" = \'%s\'',
|
'SHOW TABLE STATUS WHERE "Name" = \'%s\'',
|
||||||
'DatabaseTest_MyObject'
|
'DatabaseTest_MyObject'
|
||||||
@ -60,7 +64,6 @@ class DatabaseTest extends SapphireTest {
|
|||||||
"MySQLDatabase tables can be changed to InnoDB through DataObject::\$create_table_options"
|
"MySQLDatabase tables can be changed to InnoDB through DataObject::\$create_table_options"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function testIsSchemaUpdating() {
|
function testIsSchemaUpdating() {
|
||||||
$db = DB::getConn();
|
$db = DB::getConn();
|
||||||
|
@ -39,6 +39,6 @@ class PasswordValidatorTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testHistoricalPasswordCount() {
|
public function testHistoricalPasswordCount() {
|
||||||
// TODO
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,12 @@ class SecurityDefaultAdminTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testCheckDefaultAdmin() {
|
public function testCheckDefaultAdmin() {
|
||||||
// TODO There's currently no way to inspect default admin state,
|
if(Security::has_default_admin()) {
|
||||||
// hence we don't override existing settings
|
$this->markTestSkipped(
|
||||||
if(Security::has_default_admin()) return;
|
'Default admin present. There\'s no way to inspect default admin state, ' .
|
||||||
|
'so we don\'t override existing settings'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Security::setDefaultAdmin('admin', 'password');
|
Security::setDefaultAdmin('admin', 'password');
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testNoErrorMessageForControlWithinCached() {
|
public function testNoErrorMessageForControlWithinCached() {
|
||||||
$this->_reset(true);
|
$this->_reset(true);
|
||||||
$this->_runtemplate('<% cached %><% control Foo %>$Bar<% end_control %><% end_cached %>');
|
$this->assertNotNull($this->_runtemplate('<% cached %><% control Foo %>$Bar<% end_control %><% end_cached %>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,8 +220,8 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testNoErrorMessageForCachedWithinControlWithinUncached() {
|
public function testNoErrorMessageForCachedWithinControlWithinUncached() {
|
||||||
$this->_reset(true);
|
$this->_reset(true);
|
||||||
$this->_runtemplate(
|
$this->assertNotNull($this->_runtemplate(
|
||||||
'<% uncached %><% control Foo %><% cached %>$Bar<% end_cached %><% end_control %><% end_uncached %>');
|
'<% uncached %><% control Foo %><% cached %>$Bar<% end_cached %><% end_control %><% end_uncached %>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user