Skip to content

Commit

Permalink
Revert "MINOR Replaced assertType() calls with assertInstanceOf(), de…
Browse files Browse the repository at this point in the history
…precated in PHPUnit 3.6 (throws warnings as of 3.5.10)" - cased too many problems with mixed build environments that require PHP 3.4

This reverts commit 65f6104.
  • Loading branch information
chillu committed Mar 11, 2011
1 parent 9d10e88 commit 2184acf
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 43 deletions.
8 changes: 4 additions & 4 deletions tests/DataObjectDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ function testOneToManyAssociationWithDecorator() {
$object = DataObject::get_one('DataObjectDecoratorTest_RelatedObject', "\"ContactID\" = {$contactID}");

$this->assertNotNull($object, 'Related object not null');
$this->assertInstanceOf('DataObjectDecoratorTest_Member', $object->Contact(), 'Related contact is a member dataobject');
$this->assertInstanceOf('DataObjectDecoratorTest_Member', $object->getComponent('Contact'), 'getComponent does the same thing as Contact()');
$this->assertType('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_RelatedObject', $contact->RelatedObjects()->First());
$this->assertType('DataObjectDecoratorTest_RelatedObject', $contact->RelatedObjects()->First());
$this->assertEquals("Lorem ipsum dolor", $contact->RelatedObjects()->First()->FieldOne);
$this->assertEquals("Random notes", $contact->RelatedObjects()->First()->FieldTwo);
$contact->delete();
Expand Down Expand Up @@ -143,7 +143,7 @@ function testPopulateDefaults() {
function testDbObjectOnDecoratedFields() {
$member = $this->objFromFixture('DataObjectDecoratorTest_Member', 'member1');
$this->assertNotNull($member->dbObject('Website'));
$this->assertInstanceOf('Varchar', $member->dbObject('Website'));
$this->assertType('Varchar', $member->dbObject('Website'));
}

function testDecoratorCanBeAppliedToDataObject() {
Expand Down
4 changes: 2 additions & 2 deletions tests/DataObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ function testNewClassInstance() {
$changedFields = $changedPage->getChangedFields();

// Don't write the record, it will reset changed fields
$this->assertInstanceOf('RedirectorPage', $changedPage);
$this->assertType('RedirectorPage', $changedPage);
$this->assertEquals($changedPage->ClassName, 'RedirectorPage');
$this->assertEquals($changedPage->RedirectionType, 'Internal');
//$this->assertEquals($changedPage->RecordClassName, 'RedirectorPage');
Expand All @@ -711,7 +711,7 @@ function testNewClassInstance() {
$this->assertEquals($changedFields['ClassName']['after'], 'RedirectorPage');

$changedPage->write();
$this->assertInstanceOf('RedirectorPage', $changedPage);
$this->assertType('RedirectorPage', $changedPage);
$this->assertEquals($changedPage->ClassName, 'RedirectorPage');
}

Expand Down
8 changes: 4 additions & 4 deletions tests/ObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,19 @@ public function testGetExtensions() {
$inst = new ObjectTest_ExtensionTest();
$extensions = $inst->getExtensionInstances();
$this->assertEquals(count($extensions), 2);
$this->assertInstanceOf(
$this->assertType(
'ObjectTest_ExtendTest1',
$extensions['ObjectTest_ExtendTest1']
);
$this->assertInstanceOf(
$this->assertType(
'ObjectTest_ExtendTest2',
$extensions['ObjectTest_ExtendTest2']
);
$this->assertInstanceOf(
$this->assertType(
'ObjectTest_ExtendTest1',
$inst->getExtensionInstance('ObjectTest_ExtendTest1')
);
$this->assertInstanceOf(
$this->assertType(
'ObjectTest_ExtendTest2',
$inst->getExtensionInstance('ObjectTest_ExtendTest2')
);
Expand Down
2 changes: 1 addition & 1 deletion tests/RequestHandlingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RequestHandlingTest extends FunctionalTest {

function testConstructedWithNullRequest() {
$r = new RequestHandler();
$this->assertInstanceOf('NullHTTPRequest', $r->getRequest());
$this->assertType('NullHTTPRequest', $r->getRequest());
}

function testRequestHandlerChainingAllParams() {
Expand Down
2 changes: 1 addition & 1 deletion tests/SearchContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function testRelationshipObjectsLinkedInSearch() {

$project = $results->First();

$this->assertInstanceOf('SearchContextTest_Project', $project);
$this->assertType('SearchContextTest_Project', $project);
$this->assertEquals("Blog Website", $project->Name);
$this->assertEquals(2, $project->Actions()->Count());

Expand Down
6 changes: 3 additions & 3 deletions tests/SiteTreeActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function testActionsNoDeletePublishedRecord() {

// Get the live version of the page
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
$this->assertInstanceOf("SiteTree", $page);
$this->assertType("SiteTree", $page);

// Check that someone without the right permission can't delete the page
$editor = $this->objFromFixture('Member', 'cmsnodeleteeditor');
Expand Down Expand Up @@ -116,7 +116,7 @@ function testActionsDeletedFromStageRecord() {

// Get the live version of the page
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
$this->assertInstanceOf('SiteTree', $page);
$this->assertType('SiteTree', $page);

$actionsArr = $page->getCMSActions()->column('Name');

Expand Down Expand Up @@ -183,4 +183,4 @@ function canEdit($member = null) {
function canDelete($member = null) {
return Permission::checkMember($member, 'SiteTreeActionsTest_Page_CANDELETE');
}
}
}
4 changes: 2 additions & 2 deletions tests/SiteTreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function testParentNodeCachedInMemory() {
$child->Title = 'Page Title';
$child->setParent($parent);

$this->assertInstanceOf("SiteTree", $child->Parent);
$this->assertType("SiteTree", $child->Parent);
$this->assertEquals("Section Title", $child->Parent->Title);
}

Expand All @@ -152,7 +152,7 @@ function testParentModelReturnType() {
$child = new SiteTreeTest_PageNode();

$child->setParent($parent);
$this->assertInstanceOf('SiteTreeTest_PageNode', $child->Parent);
$this->assertType('SiteTreeTest_PageNode', $child->Parent);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/control/DirectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function testTestRequestCarriesGlobals() {
$url = 'DirectorTestRequest_Controller/' . sprintf($testfunction, ucfirst($method)) . '?' . http_build_query($fixture);
$getresponse = Director::test($url, $fixture, null, strtoupper($method), null, null, $fixture);

$this->assertInstanceOf('SS_HTTPResponse', $getresponse, 'Director::test() returns SS_HTTPResponse');
$this->assertType('SS_HTTPResponse', $getresponse, 'Director::test() returns SS_HTTPResponse');
$this->assertEquals($fixture['somekey'], $getresponse->getBody(), 'Director::test() ' . $testfunction);
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/dev/LogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ function setUp() {

function testExistingWriter() {
$writers = SS_Log::get_writers();
$this->assertInternalType('array', $writers);
$this->assertType('array', $writers);
$this->assertEquals(2, count($writers));
}

function testRemoveWriter() {
SS_Log::remove_writer($this->testEmailWriter);
$writers = SS_Log::get_writers();
$this->assertInternalType('array', $writers);
$this->assertType('array', $writers);
$this->assertEquals(1, count($writers));
SS_Log::remove_writer($this->testFileWriter);
$writers = SS_Log::get_writers();
$this->assertInternalType('array', $writers);
$this->assertType('array', $writers);
$this->assertEquals(0, count($writers));
}

Expand Down
4 changes: 2 additions & 2 deletions tests/filesystem/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ function testCreateWithFilenameWithSubfolder() {
$this->assertEquals($testfilePath, $file->Filename, '"Filename" property remains unchanged');

// TODO This should be auto-detected, see File->updateFilesystem()
// $this->assertInstanceOf('Folder', $file->Parent(), 'Parent folder is created in database');
// $this->assertType('Folder', $file->Parent(), 'Parent folder is created in database');
// $this->assertFileExists($file->Parent()->getFullPath(), 'Parent folder is created on filesystem');
// $this->assertEquals('FileTest', $file->Parent()->Name);
// $this->assertInstanceOf('Folder', $file->Parent()->Parent(), 'Grandparent folder is created in database');
// $this->assertType('Folder', $file->Parent()->Parent(), 'Grandparent folder is created in database');
// $this->assertFileExists($file->Parent()->Parent()->getFullPath(), 'Grandparent folder is created on filesystem');
// $this->assertEquals('assets', $file->Parent()->Parent()->Name);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/forms/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ function testGloballyDisabledSecurityTokenInheritsToNewForm() {
SecurityToken::enable();

$form1 = $this->getStubForm();
$this->assertInstanceOf('SecurityToken', $form1->getSecurityToken());
$this->assertType('SecurityToken', $form1->getSecurityToken());

SecurityToken::disable();

$form2 = $this->getStubForm();
$this->assertInstanceOf('NullSecurityToken', $form2->getSecurityToken());
$this->assertType('NullSecurityToken', $form2->getSecurityToken());

SecurityToken::enable();
}
Expand All @@ -257,7 +257,7 @@ function testDisableSecurityTokenDoesntAddTokenFormField() {
SecurityToken::enable();

$formWithToken = $this->getStubForm();
$this->assertInstanceOf(
$this->assertType(
'HiddenField',
$formWithToken->Fields()->fieldByName(SecurityToken::get_default_name()),
'Token field added by default'
Expand Down
8 changes: 4 additions & 4 deletions tests/model/MoneyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class MoneyTest extends SapphireTest {

function testMoneyFieldsReturnedAsObjects() {
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
$this->assertInstanceOf('Money', $obj->MyMoney);
$this->assertType('Money', $obj->MyMoney);
}


function testLoadFromFixture() {
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');

$this->assertInstanceOf('Money', $obj->MyMoney);
$this->assertType('Money', $obj->MyMoney);
$this->assertEquals($obj->MyMoney->getCurrency(), 'EUR');
$this->assertEquals($obj->MyMoney->getAmount(), 1.23);
}
Expand All @@ -42,7 +42,7 @@ function testDataObjectChangedFields() {
$this->assertNotContains('MyMoney', array_keys($changed));

// With changes
$this->assertInstanceOf('Money', $obj->MyMoney);
$this->assertType('Money', $obj->MyMoney);
$obj->MyMoney->setAmount(99);
$changed = $obj->getChangedFields();
$this->assertContains('MyMoney', array_keys($changed));
Expand Down Expand Up @@ -280,7 +280,7 @@ function testHasValue() {
function testLoadIntoDataObject() {
$obj = new MoneyTest_DataObject();

$this->assertInstanceOf('Money', $obj->obj('MyMoney'));
$this->assertType('Money', $obj->obj('MyMoney'));

$m = new Money();
$m->setValue(array(
Expand Down
2 changes: 1 addition & 1 deletion tests/model/SiteConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function testCurrentCreatesDefaultForLocale() {
$configEn = SiteConfig::current_site_config();
$configFr = SiteConfig::current_site_config('fr_FR');

$this->assertInstanceOf('SiteConfig', $configFr);
$this->assertType('SiteConfig', $configFr);
$this->assertEquals($configFr->Locale, 'fr_FR');
$this->assertEquals($configFr->Title, $configEn->Title, 'Copies title from existing config');
}
Expand Down
8 changes: 4 additions & 4 deletions tests/model/TranslatableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function testUpdateCMSFieldsOnSiteTree() {

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

$this->assertInstanceOf(
$this->assertType(
'Page',
$testPage->createTranslation('ja_JP')
);
Expand Down
4 changes: 2 additions & 2 deletions tests/model/VersionedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ function testGetIncludingDeleted() {
function testVersionedFieldsAdded() {
$obj = new VersionedTest_DataObject();
// Check that the Version column is added as a full-fledged column
$this->assertInstanceOf('Int', $obj->dbObject('Version'));
$this->assertType('Int', $obj->dbObject('Version'));

$obj2 = new VersionedTest_Subclass();
// Check that the Version column is added as a full-fledged column
$this->assertInstanceOf('Int', $obj2->dbObject('Version'));
$this->assertType('Int', $obj2->dbObject('Version'));
}

function testPublishCreateNewVersion() {
Expand Down
2 changes: 1 addition & 1 deletion tests/security/MemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function testPasswordChangeLogging() {
$this->assertTrue($record->checkPassword('test1'), "Password test1 not found in MemberRecord");

$record = $passwords->next();
$this->assertInstanceOf('DataObject', $record);
$this->assertType('DataObject', $record);
$this->assertTrue($record->checkPassword('1nitialPassword'), "Password 1nitialPassword not found in MemberRecord");
}

Expand Down
2 changes: 1 addition & 1 deletion tests/security/PasswordEncryptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class PasswordEncryptorTest extends SapphireTest {
function testCreateForCode() {
PasswordEncryptor::register('test', 'PasswordEncryptorTest_TestEncryptor');
$e = PasswordEncryptor::create_for_algorithm('test');
$this->assertInstanceOf(
$this->assertType(
'PasswordEncryptorTest_TestEncryptor',
$e
);
Expand Down
2 changes: 1 addition & 1 deletion tests/security/SecurityDefaultAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function testFindAnAdministratorCreatesNewUser() {

$admin = Security::findAnAdministrator();

$this->assertInstanceOf('Member', $admin);
$this->assertType('Member', $admin);
$this->assertTrue(Permission::checkMember($admin, 'ADMIN'));
$this->assertNull($admin->Email);
$this->assertNull($admin->Password);
Expand Down
6 changes: 3 additions & 3 deletions tests/security/SecurityTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function testIsEnabledStatic() {

function testInst() {
$inst1 = SecurityToken::inst();
$this->assertInstanceOf('SecurityToken', $inst1);
$this->assertType('SecurityToken', $inst1);
}

function testInstReturnsSingleton() {
Expand Down Expand Up @@ -111,7 +111,7 @@ function testUpdateFieldSet() {
$t->updateFieldSet($fs);
$f = $fs->dataFieldByName($t->getName());

$this->assertInstanceOf('HiddenField', $f);
$this->assertType('HiddenField', $f);
$this->assertEquals($f->Name(), $t->getName(), 'Name matches');
$this->assertEquals($f->Value(), $t->getValue(), 'Value matches');
}
Expand All @@ -123,7 +123,7 @@ function testUpdateFieldSetDoesntAddTwice() {
$t->updateFieldSet($fs); // second
$f = $fs->dataFieldByName($t->getName());

$this->assertInstanceOf('HiddenField', $f);
$this->assertType('HiddenField', $f);
$this->assertEquals(1, $fs->Count());
}

Expand Down

0 comments on commit 2184acf

Please sign in to comment.