Merge remote-tracking branch 'origin/3.0'

This commit is contained in:
Ingo Schommer 2012-11-23 15:31:08 +01:00
commit 15a687f1e7
18 changed files with 168 additions and 163 deletions

View File

@ -191,14 +191,13 @@ 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,13 +283,12 @@ 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) . "'"
); );
}
} }
/** /**

View File

@ -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,21 +542,20 @@ 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(); if($to) $infoParts .= " to '$to'";
if($to) $infoParts .= " to '$to'"; if($from) $infoParts .= " from '$from'";
if($from) $infoParts .= " from '$from'"; if($subject) $withParts[] = "subject '$subject'";
if($subject) $withParts[] = "subject '$subject'"; if($content) $withParts[] = "content '$content'";
if($content) $withParts[] = "content '$content'"; if($withParts) $infoParts .= " with " . implode(" and ", $withParts);
if($withParts) $infoParts .= " with " . implode(" and ", $withParts);
$this->assertTrue(
throw new PHPUnit_Framework_AssertionFailedError( $found,
"Failed asserting that an email was sent$infoParts." "Failed asserting that an email was sent$infoParts."
); );
}
} }
@ -594,14 +595,12 @@ 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,23 +639,21 @@ 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) );
);
}
} }
/** /**
@ -676,12 +673,11 @@ 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)
); );
}
} }
} }
@ -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();

View File

@ -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

View File

@ -26,7 +26,7 @@ class RequestHandlingTest extends FunctionalTest {
} }
public function testRequestHandlerChainingAllParams() { public function testRequestHandlerChainingAllParams() {
// TODO $this->markTestIncomplete();
} }
public function testMethodCallingOnController() { public function testMethodCallingOnController() {

View File

@ -161,7 +161,7 @@ class ConfigTest extends SapphireTest {
} }
public function testFragmentOrder() { public function testFragmentOrder() {
// $manifest = new SS_ConfigManifest(BASE_PATH, false, true); $this->markTestIncomplete();
} }
} }

View File

@ -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();

View File

@ -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'));
} }
} }

View File

@ -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() {

View File

@ -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) {

View File

@ -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);
} }
/** /**

View File

@ -11,7 +11,7 @@ class RequirementsTest extends SapphireTest {
static $html_template = '<html><head></head><body></body></html>'; static $html_template = '<html><head></head><body></body></html>';
static $old_requirements = null; static $old_requirements = null;
public function testExternalUrls() { public function testExternalUrls() {
$backend = new Requirements_Backend; $backend = new Requirements_Backend;
$backend->set_combined_files_enabled(true); $backend->set_combined_files_enabled(true);
@ -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)) . "'"
); );
}
} }
} }
} }

View File

@ -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();
} }
/* */ /* */

View File

@ -195,8 +195,8 @@ class DataListTest extends SapphireTest {
} }
public function testFilter() { public function testFilter() {
// coming soon! $this->markTestIncomplete();
} }
public function testWhere() { public function testWhere() {
// We can use raw SQL queries with where. This is only recommended for advanced uses; // We can use raw SQL queries with where. This is only recommended for advanced uses;

View File

@ -1021,23 +1021,18 @@ 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->write();
$do->delete(); $do->duplicate();
$do->write();
$do->duplicate();
}
catch(Exception $e) {
return;
}
$this->fail('Should throw an exception');
} }
public function testToMap() { public function testToMap() {

View File

@ -51,15 +51,18 @@ class DatabaseTest extends SapphireTest {
} }
public function testMySQLCreateTableOptions() { public function testMySQLCreateTableOptions() {
if(DB::getConn() instanceof MySQLDatabase) { if(!(DB::getConn() instanceof MySQLDatabase)) {
$ret = DB::query(sprintf( $this->markTestSkipped('MySQL only');
'SHOW TABLE STATUS WHERE "Name" = \'%s\'',
'DatabaseTest_MyObject'
))->first();
$this->assertEquals($ret['Engine'],'InnoDB',
"MySQLDatabase tables can be changed to InnoDB through DataObject::\$create_table_options"
);
} }
$ret = DB::query(sprintf(
'SHOW TABLE STATUS WHERE "Name" = \'%s\'',
'DatabaseTest_MyObject'
))->first();
$this->assertEquals($ret['Engine'],'InnoDB',
"MySQLDatabase tables can be changed to InnoDB through DataObject::\$create_table_options"
);
} }
function testIsSchemaUpdating() { function testIsSchemaUpdating() {

View File

@ -39,6 +39,6 @@ class PasswordValidatorTest extends SapphireTest {
} }
public function testHistoricalPasswordCount() { public function testHistoricalPasswordCount() {
// TODO $this->markTestIncomplete();
} }
} }

View File

@ -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');

View File

@ -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 %>'));
} }
/** /**