MINOR Replaced assertType() calls with assertInstanceOf(), deprecated in PHPUnit 3.6 (throws warnings as of 3.5.10)

This commit is contained in:
Ingo Schommer 2011-02-11 14:54:54 +13:00
parent ca2e80ec08
commit 65f6104cd6
19 changed files with 42 additions and 42 deletions

View File

@ -41,10 +41,10 @@ class DataObjectDecoratorTest extends SapphireTest {
$object = DataObject::get_one('DataObjectDecoratorTest_RelatedObject', "\"ContactID\" = {$contactID}"); $object = DataObject::get_one('DataObjectDecoratorTest_RelatedObject', "\"ContactID\" = {$contactID}");
$this->assertNotNull($object, 'Related object not null'); $this->assertNotNull($object, 'Related object not null');
$this->assertType('DataObjectDecoratorTest_Member', $object->Contact(), 'Related contact is a member dataobject'); $this->assertInstanceOf('DataObjectDecoratorTest_Member', $object->Contact(), 'Related contact is a member dataobject');
$this->assertType('DataObjectDecoratorTest_Member', $object->getComponent('Contact'), 'getComponent does the same thing as Contact()'); $this->assertInstanceOf('DataObjectDecoratorTest_Member', $object->getComponent('Contact'), 'getComponent does the same thing as Contact()');
$this->assertType('DataObjectDecoratorTest_RelatedObject', $contact->RelatedObjects()->First()); $this->assertInstanceOf('DataObjectDecoratorTest_RelatedObject', $contact->RelatedObjects()->First());
$this->assertEquals("Lorem ipsum dolor", $contact->RelatedObjects()->First()->FieldOne); $this->assertEquals("Lorem ipsum dolor", $contact->RelatedObjects()->First()->FieldOne);
$this->assertEquals("Random notes", $contact->RelatedObjects()->First()->FieldTwo); $this->assertEquals("Random notes", $contact->RelatedObjects()->First()->FieldTwo);
$contact->delete(); $contact->delete();
@ -143,7 +143,7 @@ class DataObjectDecoratorTest extends SapphireTest {
function testDbObjectOnDecoratedFields() { function testDbObjectOnDecoratedFields() {
$member = $this->objFromFixture('DataObjectDecoratorTest_Member', 'member1'); $member = $this->objFromFixture('DataObjectDecoratorTest_Member', 'member1');
$this->assertNotNull($member->dbObject('Website')); $this->assertNotNull($member->dbObject('Website'));
$this->assertType('Varchar', $member->dbObject('Website')); $this->assertInstanceOf('Varchar', $member->dbObject('Website'));
} }
function testDecoratorCanBeAppliedToDataObject() { function testDecoratorCanBeAppliedToDataObject() {

View File

@ -685,7 +685,7 @@ class DataObjectTest extends SapphireTest {
$changedFields = $changedPage->getChangedFields(); $changedFields = $changedPage->getChangedFields();
// Don't write the record, it will reset changed fields // Don't write the record, it will reset changed fields
$this->assertType('RedirectorPage', $changedPage); $this->assertInstanceOf('RedirectorPage', $changedPage);
$this->assertEquals($changedPage->ClassName, 'RedirectorPage'); $this->assertEquals($changedPage->ClassName, 'RedirectorPage');
$this->assertEquals($changedPage->RedirectionType, 'Internal'); $this->assertEquals($changedPage->RedirectionType, 'Internal');
//$this->assertEquals($changedPage->RecordClassName, 'RedirectorPage'); //$this->assertEquals($changedPage->RecordClassName, 'RedirectorPage');
@ -694,7 +694,7 @@ class DataObjectTest extends SapphireTest {
$this->assertEquals($changedFields['ClassName']['after'], 'RedirectorPage'); $this->assertEquals($changedFields['ClassName']['after'], 'RedirectorPage');
$changedPage->write(); $changedPage->write();
$this->assertType('RedirectorPage', $changedPage); $this->assertInstanceOf('RedirectorPage', $changedPage);
$this->assertEquals($changedPage->ClassName, 'RedirectorPage'); $this->assertEquals($changedPage->ClassName, 'RedirectorPage');
} }

View File

@ -177,19 +177,19 @@ class ObjectTest extends SapphireTest {
$inst = new ObjectTest_ExtensionTest(); $inst = new ObjectTest_ExtensionTest();
$extensions = $inst->getExtensionInstances(); $extensions = $inst->getExtensionInstances();
$this->assertEquals(count($extensions), 2); $this->assertEquals(count($extensions), 2);
$this->assertType( $this->assertInstanceOf(
'ObjectTest_ExtendTest1', 'ObjectTest_ExtendTest1',
$extensions['ObjectTest_ExtendTest1'] $extensions['ObjectTest_ExtendTest1']
); );
$this->assertType( $this->assertInstanceOf(
'ObjectTest_ExtendTest2', 'ObjectTest_ExtendTest2',
$extensions['ObjectTest_ExtendTest2'] $extensions['ObjectTest_ExtendTest2']
); );
$this->assertType( $this->assertInstanceOf(
'ObjectTest_ExtendTest1', 'ObjectTest_ExtendTest1',
$inst->getExtensionInstance('ObjectTest_ExtendTest1') $inst->getExtensionInstance('ObjectTest_ExtendTest1')
); );
$this->assertType( $this->assertInstanceOf(
'ObjectTest_ExtendTest2', 'ObjectTest_ExtendTest2',
$inst->getExtensionInstance('ObjectTest_ExtendTest2') $inst->getExtensionInstance('ObjectTest_ExtendTest2')
); );

View File

@ -22,7 +22,7 @@ class RequestHandlingTest extends FunctionalTest {
function testConstructedWithNullRequest() { function testConstructedWithNullRequest() {
$r = new RequestHandler(); $r = new RequestHandler();
$this->assertType('NullHTTPRequest', $r->getRequest()); $this->assertInstanceOf('NullHTTPRequest', $r->getRequest());
} }
function testRequestHandlerChainingAllParams() { function testRequestHandlerChainingAllParams() {

View File

@ -108,7 +108,7 @@ class SearchContextTest extends SapphireTest {
$project = $results->First(); $project = $results->First();
$this->assertType('SearchContextTest_Project', $project); $this->assertInstanceOf('SearchContextTest_Project', $project);
$this->assertEquals("Blog Website", $project->Name); $this->assertEquals("Blog Website", $project->Name);
$this->assertEquals(2, $project->Actions()->Count()); $this->assertEquals(2, $project->Actions()->Count());

View File

@ -64,7 +64,7 @@ class SiteTreeActionsTest extends FunctionalTest {
// Get the live version of the page // Get the live version of the page
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); $page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
$this->assertType("SiteTree", $page); $this->assertInstanceOf("SiteTree", $page);
// Check that someone without the right permission can't delete the page // Check that someone without the right permission can't delete the page
$editor = $this->objFromFixture('Member', 'cmsnodeleteeditor'); $editor = $this->objFromFixture('Member', 'cmsnodeleteeditor');
@ -116,7 +116,7 @@ class SiteTreeActionsTest extends FunctionalTest {
// Get the live version of the page // Get the live version of the page
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); $page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
$this->assertType('SiteTree', $page); $this->assertInstanceOf('SiteTree', $page);
$actionsArr = $page->getCMSActions()->column('Name'); $actionsArr = $page->getCMSActions()->column('Name');

View File

@ -143,7 +143,7 @@ class SiteTreeTest extends SapphireTest {
$child->Title = 'Page Title'; $child->Title = 'Page Title';
$child->setParent($parent); $child->setParent($parent);
$this->assertType("SiteTree", $child->Parent); $this->assertInstanceOf("SiteTree", $child->Parent);
$this->assertEquals("Section Title", $child->Parent->Title); $this->assertEquals("Section Title", $child->Parent->Title);
} }
@ -152,7 +152,7 @@ class SiteTreeTest extends SapphireTest {
$child = new SiteTreeTest_PageNode(); $child = new SiteTreeTest_PageNode();
$child->setParent($parent); $child->setParent($parent);
$this->assertType('SiteTreeTest_PageNode', $child->Parent); $this->assertInstanceOf('SiteTreeTest_PageNode', $child->Parent);
} }
/** /**

View File

@ -165,7 +165,7 @@ class DirectorTest extends SapphireTest {
$url = 'DirectorTestRequest_Controller/' . sprintf($testfunction, ucfirst($method)) . '?' . http_build_query($fixture); $url = 'DirectorTestRequest_Controller/' . sprintf($testfunction, ucfirst($method)) . '?' . http_build_query($fixture);
$getresponse = Director::test($url, $fixture, null, strtoupper($method), null, null, $fixture); $getresponse = Director::test($url, $fixture, null, strtoupper($method), null, null, $fixture);
$this->assertType('SS_HTTPResponse', $getresponse, 'Director::test() returns SS_HTTPResponse'); $this->assertInstanceOf('SS_HTTPResponse', $getresponse, 'Director::test() returns SS_HTTPResponse');
$this->assertEquals($fixture['somekey'], $getresponse->getBody(), 'Director::test() ' . $testfunction); $this->assertEquals($fixture['somekey'], $getresponse->getBody(), 'Director::test() ' . $testfunction);
} }
} }

View File

@ -18,18 +18,18 @@ class SS_LogTest extends SapphireTest {
function testExistingWriter() { function testExistingWriter() {
$writers = SS_Log::get_writers(); $writers = SS_Log::get_writers();
$this->assertType('array', $writers); $this->assertInternalType('array', $writers);
$this->assertEquals(2, count($writers)); $this->assertEquals(2, count($writers));
} }
function testRemoveWriter() { function testRemoveWriter() {
SS_Log::remove_writer($this->testEmailWriter); SS_Log::remove_writer($this->testEmailWriter);
$writers = SS_Log::get_writers(); $writers = SS_Log::get_writers();
$this->assertType('array', $writers); $this->assertInternalType('array', $writers);
$this->assertEquals(1, count($writers)); $this->assertEquals(1, count($writers));
SS_Log::remove_writer($this->testFileWriter); SS_Log::remove_writer($this->testFileWriter);
$writers = SS_Log::get_writers(); $writers = SS_Log::get_writers();
$this->assertType('array', $writers); $this->assertInternalType('array', $writers);
$this->assertEquals(0, count($writers)); $this->assertEquals(0, count($writers));
} }

View File

@ -27,10 +27,10 @@ class FileTest extends SapphireTest {
$this->assertEquals($testfilePath, $file->Filename, '"Filename" property remains unchanged'); $this->assertEquals($testfilePath, $file->Filename, '"Filename" property remains unchanged');
// TODO This should be auto-detected, see File->updateFilesystem() // TODO This should be auto-detected, see File->updateFilesystem()
// $this->assertType('Folder', $file->Parent(), 'Parent folder is created in database'); // $this->assertInstanceOf('Folder', $file->Parent(), 'Parent folder is created in database');
// $this->assertFileExists($file->Parent()->getFullPath(), 'Parent folder is created on filesystem'); // $this->assertFileExists($file->Parent()->getFullPath(), 'Parent folder is created on filesystem');
// $this->assertEquals('FileTest', $file->Parent()->Name); // $this->assertEquals('FileTest', $file->Parent()->Name);
// $this->assertType('Folder', $file->Parent()->Parent(), 'Grandparent folder is created in database'); // $this->assertInstanceOf('Folder', $file->Parent()->Parent(), 'Grandparent folder is created in database');
// $this->assertFileExists($file->Parent()->Parent()->getFullPath(), 'Grandparent folder is created on filesystem'); // $this->assertFileExists($file->Parent()->Parent()->getFullPath(), 'Grandparent folder is created on filesystem');
// $this->assertEquals('assets', $file->Parent()->Parent()->Name); // $this->assertEquals('assets', $file->Parent()->Parent()->Name);
} }

View File

@ -243,12 +243,12 @@ class FormTest extends FunctionalTest {
SecurityToken::enable(); SecurityToken::enable();
$form1 = $this->getStubForm(); $form1 = $this->getStubForm();
$this->assertType('SecurityToken', $form1->getSecurityToken()); $this->assertInstanceOf('SecurityToken', $form1->getSecurityToken());
SecurityToken::disable(); SecurityToken::disable();
$form2 = $this->getStubForm(); $form2 = $this->getStubForm();
$this->assertType('NullSecurityToken', $form2->getSecurityToken()); $this->assertInstanceOf('NullSecurityToken', $form2->getSecurityToken());
SecurityToken::enable(); SecurityToken::enable();
} }
@ -257,7 +257,7 @@ class FormTest extends FunctionalTest {
SecurityToken::enable(); SecurityToken::enable();
$formWithToken = $this->getStubForm(); $formWithToken = $this->getStubForm();
$this->assertType( $this->assertInstanceOf(
'HiddenField', 'HiddenField',
$formWithToken->Fields()->fieldByName(SecurityToken::get_default_name()), $formWithToken->Fields()->fieldByName(SecurityToken::get_default_name()),
'Token field added by default' 'Token field added by default'

View File

@ -21,14 +21,14 @@ class MoneyTest extends SapphireTest {
function testMoneyFieldsReturnedAsObjects() { function testMoneyFieldsReturnedAsObjects() {
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1'); $obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
$this->assertType('Money', $obj->MyMoney); $this->assertInstanceOf('Money', $obj->MyMoney);
} }
function testLoadFromFixture() { function testLoadFromFixture() {
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1'); $obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
$this->assertType('Money', $obj->MyMoney); $this->assertInstanceOf('Money', $obj->MyMoney);
$this->assertEquals($obj->MyMoney->getCurrency(), 'EUR'); $this->assertEquals($obj->MyMoney->getCurrency(), 'EUR');
$this->assertEquals($obj->MyMoney->getAmount(), 1.23); $this->assertEquals($obj->MyMoney->getAmount(), 1.23);
} }
@ -42,7 +42,7 @@ class MoneyTest extends SapphireTest {
$this->assertNotContains('MyMoney', array_keys($changed)); $this->assertNotContains('MyMoney', array_keys($changed));
// With changes // With changes
$this->assertType('Money', $obj->MyMoney); $this->assertInstanceOf('Money', $obj->MyMoney);
$obj->MyMoney->setAmount(99); $obj->MyMoney->setAmount(99);
$changed = $obj->getChangedFields(); $changed = $obj->getChangedFields();
$this->assertContains('MyMoney', array_keys($changed)); $this->assertContains('MyMoney', array_keys($changed));
@ -280,7 +280,7 @@ class MoneyTest extends SapphireTest {
function testLoadIntoDataObject() { function testLoadIntoDataObject() {
$obj = new MoneyTest_DataObject(); $obj = new MoneyTest_DataObject();
$this->assertType('Money', $obj->obj('MyMoney')); $this->assertInstanceOf('Money', $obj->obj('MyMoney'));
$m = new Money(); $m = new Money();
$m->setValue(array( $m->setValue(array(

View File

@ -39,7 +39,7 @@ class SiteConfigTest extends SapphireTest {
$configEn = SiteConfig::current_site_config(); $configEn = SiteConfig::current_site_config();
$configFr = SiteConfig::current_site_config('fr_FR'); $configFr = SiteConfig::current_site_config('fr_FR');
$this->assertType('SiteConfig', $configFr); $this->assertInstanceOf('SiteConfig', $configFr);
$this->assertEquals($configFr->Locale, 'fr_FR'); $this->assertEquals($configFr->Locale, 'fr_FR');
$this->assertEquals($configFr->Title, $configEn->Title, 'Copies title from existing config'); $this->assertEquals($configFr->Title, $configEn->Title, 'Copies title from existing config');
} }

View File

@ -220,7 +220,7 @@ class TranslatableTest extends FunctionalTest {
// first test with default language // first test with default language
$fields = $pageOrigLang->getCMSFields(); $fields = $pageOrigLang->getCMSFields();
$this->assertType( $this->assertInstanceOf(
'TextField', 'TextField',
$fields->dataFieldByName('Title'), $fields->dataFieldByName('Title'),
'Translatable doesnt modify fields if called in default language (e.g. "non-translation mode")' 'Translatable doesnt modify fields if called in default language (e.g. "non-translation mode")'
@ -233,13 +233,13 @@ class TranslatableTest extends FunctionalTest {
// then in "translation mode" // then in "translation mode"
$pageTranslated = $pageOrigLang->createTranslation('fr_FR'); $pageTranslated = $pageOrigLang->createTranslation('fr_FR');
$fields = $pageTranslated->getCMSFields(); $fields = $pageTranslated->getCMSFields();
$this->assertType( $this->assertInstanceOf(
'TextField', 'TextField',
$fields->dataFieldByName('Title'), $fields->dataFieldByName('Title'),
'Translatable leaves original formfield intact in "translation mode"' 'Translatable leaves original formfield intact in "translation mode"'
); );
$readonlyField = $fields->dataFieldByName('Title')->performReadonlyTransformation(); $readonlyField = $fields->dataFieldByName('Title')->performReadonlyTransformation();
$this->assertType( $this->assertInstanceOf(
$readonlyField->class, $readonlyField->class,
$fields->dataFieldByName('Title_original'), $fields->dataFieldByName('Title_original'),
'Translatable adds the original value as a ReadonlyField in "translation mode"' 'Translatable adds the original value as a ReadonlyField in "translation mode"'
@ -793,7 +793,7 @@ class TranslatableTest extends FunctionalTest {
"Users with canEdit() and TRANSLATE_ALL permission can't create a new translation if locale is not in Translatable::get_allowed_locales()" "Users with canEdit() and TRANSLATE_ALL permission can't create a new translation if locale is not in Translatable::get_allowed_locales()"
); );
$this->assertType( $this->assertInstanceOf(
'Page', 'Page',
$testPage->createTranslation('ja_JP') $testPage->createTranslation('ja_JP')
); );

View File

@ -94,11 +94,11 @@ class VersionedTest extends SapphireTest {
function testVersionedFieldsAdded() { function testVersionedFieldsAdded() {
$obj = new VersionedTest_DataObject(); $obj = new VersionedTest_DataObject();
// Check that the Version column is added as a full-fledged column // Check that the Version column is added as a full-fledged column
$this->assertType('Int', $obj->dbObject('Version')); $this->assertInstanceOf('Int', $obj->dbObject('Version'));
$obj2 = new VersionedTest_Subclass(); $obj2 = new VersionedTest_Subclass();
// Check that the Version column is added as a full-fledged column // Check that the Version column is added as a full-fledged column
$this->assertType('Int', $obj2->dbObject('Version')); $this->assertInstanceOf('Int', $obj2->dbObject('Version'));
} }
function testPublishCreateNewVersion() { function testPublishCreateNewVersion() {

View File

@ -150,7 +150,7 @@ class MemberTest extends FunctionalTest {
$this->assertTrue($record->checkPassword('test1'), "Password test1 not found in MemberRecord"); $this->assertTrue($record->checkPassword('test1'), "Password test1 not found in MemberRecord");
$record = $passwords->next(); $record = $passwords->next();
$this->assertType('DataObject', $record); $this->assertInstanceOf('DataObject', $record);
$this->assertTrue($record->checkPassword('1nitialPassword'), "Password 1nitialPassword not found in MemberRecord"); $this->assertTrue($record->checkPassword('1nitialPassword'), "Password 1nitialPassword not found in MemberRecord");
} }

View File

@ -3,7 +3,7 @@ class PasswordEncryptorTest extends SapphireTest {
function testCreateForCode() { function testCreateForCode() {
PasswordEncryptor::register('test', 'PasswordEncryptorTest_TestEncryptor'); PasswordEncryptor::register('test', 'PasswordEncryptorTest_TestEncryptor');
$e = PasswordEncryptor::create_for_algorithm('test'); $e = PasswordEncryptor::create_for_algorithm('test');
$this->assertType( $this->assertInstanceOf(
'PasswordEncryptorTest_TestEncryptor', 'PasswordEncryptorTest_TestEncryptor',
$e $e
); );

View File

@ -40,7 +40,7 @@ class SecurityDefaultAdminTest extends SapphireTest {
$admin = Security::findAnAdministrator(); $admin = Security::findAnAdministrator();
$this->assertType('Member', $admin); $this->assertInstanceOf('Member', $admin);
$this->assertTrue(Permission::checkMember($admin, 'ADMIN')); $this->assertTrue(Permission::checkMember($admin, 'ADMIN'));
$this->assertNull($admin->Email); $this->assertNull($admin->Email);
$this->assertNull($admin->Password); $this->assertNull($admin->Password);

View File

@ -41,7 +41,7 @@ class SecurityTokenTest extends SapphireTest {
function testInst() { function testInst() {
$inst1 = SecurityToken::inst(); $inst1 = SecurityToken::inst();
$this->assertType('SecurityToken', $inst1); $this->assertInstanceOf('SecurityToken', $inst1);
} }
function testInstReturnsSingleton() { function testInstReturnsSingleton() {
@ -111,7 +111,7 @@ class SecurityTokenTest extends SapphireTest {
$t->updateFieldSet($fs); $t->updateFieldSet($fs);
$f = $fs->dataFieldByName($t->getName()); $f = $fs->dataFieldByName($t->getName());
$this->assertType('HiddenField', $f); $this->assertInstanceOf('HiddenField', $f);
$this->assertEquals($f->Name(), $t->getName(), 'Name matches'); $this->assertEquals($f->Name(), $t->getName(), 'Name matches');
$this->assertEquals($f->Value(), $t->getValue(), 'Value matches'); $this->assertEquals($f->Value(), $t->getValue(), 'Value matches');
} }
@ -123,7 +123,7 @@ class SecurityTokenTest extends SapphireTest {
$t->updateFieldSet($fs); // second $t->updateFieldSet($fs); // second
$f = $fs->dataFieldByName($t->getName()); $f = $fs->dataFieldByName($t->getName());
$this->assertType('HiddenField', $f); $this->assertInstanceOf('HiddenField', $f);
$this->assertEquals(1, $fs->Count()); $this->assertEquals(1, $fs->Count());
} }