From b1e17578c776b4f100803f155c35df86fe45d92a Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 9 May 2012 22:43:22 +1200 Subject: [PATCH] API CHANGE Removed assertType() and assertEmpty() workarounds. Use assertInstanceOf() instead of assertType(), assertEmpty() is available in PHPUnit 3.5+. PHPUnit 3.4 is no longer supported, so please upgrade your version to work. MINOR Removed FullTestSuite which was a workaround for PHPUnit but not used. --- admin/tests/CMSMenuTest.php | 6 +- admin/tests/LeftAndMainTest.php | 2 +- dev/SapphireTest.php | 55 ------------ tests/FullTestSuite.php | 83 ------------------- tests/control/DirectorTest.php | 2 +- tests/control/RequestHandlingTest.php | 2 +- tests/core/ObjectTest.php | 8 +- tests/dev/LogTest.php | 4 +- tests/filesystem/FileTest.php | 4 +- tests/forms/FormTest.php | 6 +- tests/forms/gridfield/GridFieldConfigTest.php | 2 +- tests/i18n/i18nTest.php | 4 +- tests/model/DataExtensionTest.php | 8 +- tests/model/DataListTest.php | 2 +- tests/model/DataObjectLazyLoadingTest.php | 2 +- tests/model/DataObjectTest.php | 4 +- tests/model/MoneyTest.php | 8 +- tests/model/VersionedTest.php | 4 +- tests/search/SearchContextTest.php | 2 +- tests/security/MemberTest.php | 2 +- tests/security/PasswordEncryptorTest.php | 2 +- tests/security/SecurityDefaultAdminTest.php | 2 +- tests/security/SecurityTokenTest.php | 6 +- 23 files changed, 40 insertions(+), 180 deletions(-) delete mode 100644 tests/FullTestSuite.php diff --git a/admin/tests/CMSMenuTest.php b/admin/tests/CMSMenuTest.php index 835322876..8a3dcbf0d 100644 --- a/admin/tests/CMSMenuTest.php +++ b/admin/tests/CMSMenuTest.php @@ -16,7 +16,7 @@ class CMSMenuTest extends SapphireTest implements TestOnly { CMSMenu::add_controller('CMSMenuTest_LeftAndMainController'); $menuItems = CMSMenu::get_menu_items(); $menuItem = $menuItems['CMSMenuTest_LeftAndMainController']; - $this->assertType('CMSMenuItem', $menuItem, 'Controller menu item is of class CMSMenuItem'); + $this->assertInstanceOf('CMSMenuItem', $menuItem, 'Controller menu item is of class CMSMenuItem'); $this->assertEquals($menuItem->url, singleton('CMSMenuTest_LeftAndMainController')->Link(), 'Controller menu item has the correct link'); $this->assertEquals($menuItem->controller, 'CMSMenuTest_LeftAndMainController', 'Controller menu item has the correct controller class'); $this->assertEquals($menuItem->priority, singleton('CMSMenuTest_LeftAndMainController')->stat('menu_priority'), 'Controller menu item has the correct priority'); @@ -26,7 +26,7 @@ class CMSMenuTest extends SapphireTest implements TestOnly { CMSMenu::add_link('LinkCode', 'link title', 'http://www.example.com'); $menuItems = CMSMenu::get_menu_items(); $menuItem = $menuItems['LinkCode']; - $this->assertType('CMSMenuItem', $menuItem, 'Link menu item is of class CMSMenuItem'); + $this->assertInstanceOf('CMSMenuItem', $menuItem, 'Link menu item is of class CMSMenuItem'); $this->assertEquals($menuItem->title, 'link title', 'Link menu item has the correct title'); $this->assertEquals($menuItem->url,'http://www.example.com', 'Link menu item has the correct link'); $this->assertNull($menuItem->controller, 'Link menu item has no controller class'); @@ -53,7 +53,7 @@ class CMSMenuTest extends SapphireTest implements TestOnly { CMSMenu::clear_menu(); CMSMenu::populate_menu(); $menuItem = CMSMenu::get_menu_item('SecurityAdmin'); - $this->assertType('CMSMenuItem', $menuItem, 'SecurityAdmin menu item exists'); + $this->assertInstanceOf('CMSMenuItem', $menuItem, 'SecurityAdmin menu item exists'); $this->assertEquals($menuItem->url, singleton('SecurityAdmin')->Link(), 'Menu item has the correct link'); $this->assertEquals($menuItem->controller, 'SecurityAdmin', 'Menu item has the correct controller class'); $this->assertEquals( diff --git a/admin/tests/LeftAndMainTest.php b/admin/tests/LeftAndMainTest.php index 97f642ef1..815ac5d0f 100644 --- a/admin/tests/LeftAndMainTest.php +++ b/admin/tests/LeftAndMainTest.php @@ -98,7 +98,7 @@ class LeftAndMainTest extends FunctionalTest { $response = $this->get($link); - $this->assertType('SS_HTTPResponse', $response, "$link should return a response object"); + $this->assertInstanceOf('SS_HTTPResponse', $response, "$link should return a response object"); $this->assertEquals(200, $response->getStatusCode(), "$link should return 200 status code"); // Check that a HTML page has been returned $this->assertRegExp('/]*>/i', $response->getBody(), "$link should contain tag"); diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index e27bf19f2..d4a6205b8 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -652,61 +652,6 @@ class SapphireTest extends PHPUnit_Framework_TestCase { } } - /** - * Backported from PHPUnit 3.4 in order to maintain backwards - * compatibility: assertType() is deprecated in PHPUnit 3.5 (with PHP 5.2.7+), - * but as SilverStripe 2.3 and 2.4 support PHP 5.1 we can't require it. - */ - public static function assertType($expected, $actual, $message = '') { - // PHPUnit_Util_DeprecatedFeature_Logger::log( - // 'assertType() will be removed in PHPUnit 3.6 and should no longer ' . - // 'be used. assertInternalType() should be used for asserting ' . - // 'internal types such as "integer" or "string" whereas ' . - // 'assertInstanceOf() should be used for asserting that an object is ' . - // 'an instance of a specified class or interface.' - // ); - - if (is_string($expected)) { - if (PHPUnit_Util_Type::isType($expected)) { - $constraint = new PHPUnit_Framework_Constraint_IsType( - $expected - ); - } - - else if (class_exists($expected) || interface_exists($expected)) { - $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf( - $expected - ); - } - - else { - throw PHPUnit_Util_InvalidArgumentHelper::factory( - 1, 'class or interface name' - ); - } - } else { - throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); - } - - self::assertThat($actual, $constraint, $message); - } - - /** - * Provide assertEmpty() in PHPUnit <3.5. - * We want to support PHPUnit 3.4, as this is the most recent release available - * to environments running PHP <=5.2.6, such as Debian Lenny. - */ - public static function assertEmpty($item, $message = '') { - if(class_exists('PHPUnit_Framework_Constraint_IsEmpty')) { - parent::assertEmpty($item, $message); - } else { - if(!empty($item)) { - $message = $message ? $message : "Failed asserting that " . var_export($item, true) . " is empty."; - throw new PHPUnit_Framework_AssertionFailedError($message); - } - } - } - /** * Helper function for the DOS matchers */ diff --git a/tests/FullTestSuite.php b/tests/FullTestSuite.php deleted file mode 100644 index 6a51f02ab..000000000 --- a/tests/FullTestSuite.php +++ /dev/null @@ -1,83 +0,0 @@ -addTest(new SapphireTestSuite($className)); - } - - return $suite; - } - - /** - * @return Array - */ - public static function get_all_tests() { - require_once(dirname(__FILE__) . '/bootstrap.php'); - - TestRunner::use_test_manifest(); - $tests = ClassInfo::subclassesFor('SapphireTest'); - array_shift($tests); - - return $tests; - } - - /** - * Run tests for one or more "modules". - * A module is generally a toplevel folder, e.g. "mysite" or "framework". - * - * @param String $nameStr - * @return Array - */ - protected static function get_module_tests($namesStr) { - require_once(dirname(__FILE__) . '/bootstrap.php'); - - $tests = array(); - $names = explode(',', $namesStr); - foreach($names as $name) { - $classesForModule = ClassInfo::classes_for_folder($name); - if($classesForModule) foreach($classesForModule as $class) { - if(class_exists($class) && is_subclass_of($class, 'SapphireTest')) { - $tests[] = $class; - } - } - } - - return $tests; - } -} - diff --git a/tests/control/DirectorTest.php b/tests/control/DirectorTest.php index 0a273e887..97192e10c 100644 --- a/tests/control/DirectorTest.php +++ b/tests/control/DirectorTest.php @@ -165,7 +165,7 @@ class DirectorTest extends SapphireTest { $url = 'DirectorTestRequest_Controller/' . sprintf($testfunction, ucfirst($method)) . '?' . http_build_query($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); } } diff --git a/tests/control/RequestHandlingTest.php b/tests/control/RequestHandlingTest.php index 0454332a5..10837ee3a 100644 --- a/tests/control/RequestHandlingTest.php +++ b/tests/control/RequestHandlingTest.php @@ -22,7 +22,7 @@ class RequestHandlingTest extends FunctionalTest { function testConstructedWithNullRequest() { $r = new RequestHandler(); - $this->assertType('NullHTTPRequest', $r->getRequest()); + $this->assertInstanceOf('NullHTTPRequest', $r->getRequest()); } function testRequestHandlerChainingAllParams() { diff --git a/tests/core/ObjectTest.php b/tests/core/ObjectTest.php index 39cada147..6e62ad276 100644 --- a/tests/core/ObjectTest.php +++ b/tests/core/ObjectTest.php @@ -165,19 +165,19 @@ class ObjectTest extends SapphireTest { $inst = new ObjectTest_ExtensionTest(); $extensions = $inst->getExtensionInstances(); $this->assertEquals(count($extensions), 2); - $this->assertType( + $this->assertInstanceOf( 'ObjectTest_ExtendTest1', $extensions['ObjectTest_ExtendTest1'] ); - $this->assertType( + $this->assertInstanceOf( 'ObjectTest_ExtendTest2', $extensions['ObjectTest_ExtendTest2'] ); - $this->assertType( + $this->assertInstanceOf( 'ObjectTest_ExtendTest1', $inst->getExtensionInstance('ObjectTest_ExtendTest1') ); - $this->assertType( + $this->assertInstanceOf( 'ObjectTest_ExtendTest2', $inst->getExtensionInstance('ObjectTest_ExtendTest2') ); diff --git a/tests/dev/LogTest.php b/tests/dev/LogTest.php index 65664d9dd..2ceafb4a5 100644 --- a/tests/dev/LogTest.php +++ b/tests/dev/LogTest.php @@ -26,7 +26,6 @@ class SS_LogTest extends SapphireTest { SS_Log::add_writer($testFileWriter, SS_Log::WARN); $writers = SS_Log::get_writers(); - $this->assertType('array', $writers); $this->assertEquals(2, count($writers)); } @@ -38,12 +37,11 @@ class SS_LogTest extends SapphireTest { SS_Log::remove_writer($testEmailWriter); $writers = SS_Log::get_writers(); - $this->assertType('array', $writers); + $this->assertEquals(1, count($writers)); SS_Log::remove_writer($testFileWriter); $writers = SS_Log::get_writers(); - $this->assertType('array', $writers); $this->assertEquals(0, count($writers)); } diff --git a/tests/filesystem/FileTest.php b/tests/filesystem/FileTest.php index 8c1e36b30..04e18361f 100644 --- a/tests/filesystem/FileTest.php +++ b/tests/filesystem/FileTest.php @@ -61,10 +61,10 @@ class FileTest extends SapphireTest { $this->assertEquals($testfilePath, $file->Filename, '"Filename" property remains unchanged'); // 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->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->assertEquals('assets', $file->Parent()->Parent()->Name); } diff --git a/tests/forms/FormTest.php b/tests/forms/FormTest.php index ab90ff7b8..c7ca8ec58 100644 --- a/tests/forms/FormTest.php +++ b/tests/forms/FormTest.php @@ -241,12 +241,12 @@ class FormTest extends FunctionalTest { SecurityToken::enable(); $form1 = $this->getStubForm(); - $this->assertType('SecurityToken', $form1->getSecurityToken()); + $this->assertInstanceOf('SecurityToken', $form1->getSecurityToken()); SecurityToken::disable(); $form2 = $this->getStubForm(); - $this->assertType('NullSecurityToken', $form2->getSecurityToken()); + $this->assertInstanceOf('NullSecurityToken', $form2->getSecurityToken()); SecurityToken::enable(); } @@ -255,7 +255,7 @@ class FormTest extends FunctionalTest { SecurityToken::enable(); $formWithToken = $this->getStubForm(); - $this->assertType( + $this->assertInstanceOf( 'HiddenField', $formWithToken->Fields()->fieldByName(SecurityToken::get_default_name()), 'Token field added by default' diff --git a/tests/forms/gridfield/GridFieldConfigTest.php b/tests/forms/gridfield/GridFieldConfigTest.php index 83179ede9..710a916f8 100644 --- a/tests/forms/gridfield/GridFieldConfigTest.php +++ b/tests/forms/gridfield/GridFieldConfigTest.php @@ -8,7 +8,7 @@ class GridFieldConfigTest extends SapphireTest { function testGetComponents() { $config = GridFieldConfig::create(); - $this->assertType('ArrayList', $config->getComponents()); + $this->assertInstanceOf('ArrayList', $config->getComponents()); $this->assertEquals($config->getComponents()->Count(), 0); $config diff --git a/tests/i18n/i18nTest.php b/tests/i18n/i18nTest.php index ca0ac6392..7fe513209 100644 --- a/tests/i18n/i18nTest.php +++ b/tests/i18n/i18nTest.php @@ -441,8 +441,8 @@ class i18nTest extends SapphireTest { i18n::register_translator($translator, 'custom', 10); $translators = i18n::get_translators(); $this->assertArrayHasKey('custom', $translators[10]); - $this->assertType('Zend_Translate', $translators[10]['custom']); - $this->assertType('i18nTest_CustomTranslatorAdapter', $translators[10]['custom']->getAdapter()); + $this->assertInstanceOf('Zend_Translate', $translators[10]['custom']); + $this->assertInstanceOf('i18nTest_CustomTranslatorAdapter', $translators[10]['custom']->getAdapter()); i18n::unregister_translator('custom'); $translators = i18n::get_translators(); diff --git a/tests/model/DataExtensionTest.php b/tests/model/DataExtensionTest.php index d2408dce4..8165c271f 100644 --- a/tests/model/DataExtensionTest.php +++ b/tests/model/DataExtensionTest.php @@ -41,10 +41,10 @@ class DataExtensionTest extends SapphireTest { $object = DataObject::get_one('DataExtensionTest_RelatedObject', "\"ContactID\" = {$contactID}"); $this->assertNotNull($object, 'Related object not null'); - $this->assertType('DataExtensionTest_Member', $object->Contact(), 'Related contact is a member dataobject'); - $this->assertType('DataExtensionTest_Member', $object->getComponent('Contact'), 'getComponent does the same thing as Contact()'); + $this->assertInstanceOf('DataExtensionTest_Member', $object->Contact(), 'Related contact is a member dataobject'); + $this->assertInstanceOf('DataExtensionTest_Member', $object->getComponent('Contact'), 'getComponent does the same thing as Contact()'); - $this->assertType('DataExtensionTest_RelatedObject', $contact->RelatedObjects()->First()); + $this->assertInstanceOf('DataExtensionTest_RelatedObject', $contact->RelatedObjects()->First()); $this->assertEquals("Lorem ipsum dolor", $contact->RelatedObjects()->First()->FieldOne); $this->assertEquals("Random notes", $contact->RelatedObjects()->First()->FieldTwo); $contact->delete(); @@ -143,7 +143,7 @@ class DataExtensionTest extends SapphireTest { function testDbObjectOnExtendedFields() { $member = $this->objFromFixture('DataExtensionTest_Member', 'member1'); $this->assertNotNull($member->dbObject('Website')); - $this->assertType('Varchar', $member->dbObject('Website')); + $this->assertInstanceOf('Varchar', $member->dbObject('Website')); } function testExtensionCanBeAppliedToDataObject() { diff --git a/tests/model/DataListTest.php b/tests/model/DataListTest.php index 45ce64531..68b1fbe8a 100755 --- a/tests/model/DataListTest.php +++ b/tests/model/DataListTest.php @@ -161,7 +161,7 @@ class DataListTest extends SapphireTest { $team = DataList::create("DataObjectTest_Team")->byID($id); // byID() returns a DataObject, rather than a DataList - $this->assertType('DataObjectTest_Team', $team); + $this->assertInstanceOf('DataObjectTest_Team', $team); $this->assertEquals('Team 2', $team->Title); } diff --git a/tests/model/DataObjectLazyLoadingTest.php b/tests/model/DataObjectLazyLoadingTest.php index 35de74cc7..5008fd8f9 100644 --- a/tests/model/DataObjectLazyLoadingTest.php +++ b/tests/model/DataObjectLazyLoadingTest.php @@ -187,7 +187,7 @@ class DataObjectLazyLoadingTest extends SapphireTest { $subteam1Lazy = $teams->find('ID', $subteam1->ID); $parentTeamLazy = $subteam1Lazy->ParentTeam(); - $this->assertType('DataObjectTest_Team', $parentTeamLazy); + $this->assertInstanceOf('DataObjectTest_Team', $parentTeamLazy); $this->assertEquals($parentTeam->ID, $parentTeamLazy->ID); } diff --git a/tests/model/DataObjectTest.php b/tests/model/DataObjectTest.php index 64f0d27e8..0d88f0ace 100644 --- a/tests/model/DataObjectTest.php +++ b/tests/model/DataObjectTest.php @@ -719,7 +719,7 @@ class DataObjectTest extends SapphireTest { $changedFields = $changedDO->getChangedFields(); // Don't write the record, it will reset changed fields - $this->assertType('DataObjectTest_SubTeam', $changedDO); + $this->assertInstanceOf('DataObjectTest_SubTeam', $changedDO); $this->assertEquals($changedDO->ClassName, 'DataObjectTest_SubTeam'); $this->assertContains('ClassName', array_keys($changedFields)); $this->assertEquals($changedFields['ClassName']['before'], 'DataObjectTest_Team'); @@ -727,7 +727,7 @@ class DataObjectTest extends SapphireTest { $changedDO->write(); - $this->assertType('DataObjectTest_SubTeam', $changedDO); + $this->assertInstanceOf('DataObjectTest_SubTeam', $changedDO); $this->assertEquals($changedDO->ClassName, 'DataObjectTest_SubTeam'); } diff --git a/tests/model/MoneyTest.php b/tests/model/MoneyTest.php index b17d750ab..184dccd44 100644 --- a/tests/model/MoneyTest.php +++ b/tests/model/MoneyTest.php @@ -21,14 +21,14 @@ class MoneyTest extends SapphireTest { function testMoneyFieldsReturnedAsObjects() { $obj = $this->objFromFixture('MoneyTest_DataObject', 'test1'); - $this->assertType('Money', $obj->MyMoney); + $this->assertInstanceOf('Money', $obj->MyMoney); } function testLoadFromFixture() { $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->getAmount(), 1.23); } @@ -42,7 +42,7 @@ class MoneyTest extends SapphireTest { $this->assertNotContains('MyMoney', array_keys($changed)); // With changes - $this->assertType('Money', $obj->MyMoney); + $this->assertInstanceOf('Money', $obj->MyMoney); $obj->MyMoney->setAmount(99); $changed = $obj->getChangedFields(); $this->assertContains('MyMoney', array_keys($changed), 'Field is detected as changed'); @@ -229,7 +229,7 @@ class MoneyTest extends SapphireTest { function testLoadIntoDataObject() { $obj = new MoneyTest_DataObject(); - $this->assertType('Money', $obj->obj('MyMoney')); + $this->assertInstanceOf('Money', $obj->obj('MyMoney')); $m = new Money(); $m->setValue(array( diff --git a/tests/model/VersionedTest.php b/tests/model/VersionedTest.php index 99366089c..8ccaac40d 100644 --- a/tests/model/VersionedTest.php +++ b/tests/model/VersionedTest.php @@ -94,11 +94,11 @@ class VersionedTest extends SapphireTest { function testVersionedFieldsAdded() { $obj = new VersionedTest_DataObject(); // 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(); // 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() { diff --git a/tests/search/SearchContextTest.php b/tests/search/SearchContextTest.php index c806ba2f0..2e3156e85 100644 --- a/tests/search/SearchContextTest.php +++ b/tests/search/SearchContextTest.php @@ -108,7 +108,7 @@ class SearchContextTest extends SapphireTest { $project = $results->First(); - $this->assertType('SearchContextTest_Project', $project); + $this->assertInstanceOf('SearchContextTest_Project', $project); $this->assertEquals("Blog Website", $project->Name); $this->assertEquals(2, $project->Actions()->Count()); diff --git a/tests/security/MemberTest.php b/tests/security/MemberTest.php index 4e81c6e36..d7f8d0764 100644 --- a/tests/security/MemberTest.php +++ b/tests/security/MemberTest.php @@ -150,7 +150,7 @@ class MemberTest extends FunctionalTest { $this->assertTrue($passwords->current()->checkPassword('test1'), "Password test1 not found in MemberRecord"); $passwords->next(); - $this->assertType('DataObject', $passwords->current()); + $this->assertInstanceOf('DataObject', $passwords->current()); $this->assertTrue($passwords->current()->checkPassword('1nitialPassword'), "Password 1nitialPassword not found in MemberRecord"); } diff --git a/tests/security/PasswordEncryptorTest.php b/tests/security/PasswordEncryptorTest.php index a12325cde..1c990bb5b 100644 --- a/tests/security/PasswordEncryptorTest.php +++ b/tests/security/PasswordEncryptorTest.php @@ -20,7 +20,7 @@ class PasswordEncryptorTest extends SapphireTest { function testCreateForCode() { Config::inst()->update('PasswordEncryptor', 'encryptors', array('test'=>array('PasswordEncryptorTest_TestEncryptor'=>null))); $e = PasswordEncryptor::create_for_algorithm('test'); - $this->assertType('PasswordEncryptorTest_TestEncryptor', $e ); + $this->assertInstanceOf('PasswordEncryptorTest_TestEncryptor', $e ); } /** diff --git a/tests/security/SecurityDefaultAdminTest.php b/tests/security/SecurityDefaultAdminTest.php index 08e8743ec..a36f8c8a1 100644 --- a/tests/security/SecurityDefaultAdminTest.php +++ b/tests/security/SecurityDefaultAdminTest.php @@ -40,7 +40,7 @@ class SecurityDefaultAdminTest extends SapphireTest { $admin = Security::findAnAdministrator(); - $this->assertType('Member', $admin); + $this->assertInstanceOf('Member', $admin); $this->assertTrue(Permission::checkMember($admin, 'ADMIN')); $this->assertNull($admin->Email); $this->assertNull($admin->Password); diff --git a/tests/security/SecurityTokenTest.php b/tests/security/SecurityTokenTest.php index 427cd422d..7874bf10b 100644 --- a/tests/security/SecurityTokenTest.php +++ b/tests/security/SecurityTokenTest.php @@ -41,7 +41,7 @@ class SecurityTokenTest extends SapphireTest { function testInst() { $inst1 = SecurityToken::inst(); - $this->assertType('SecurityToken', $inst1); + $this->assertInstanceOf('SecurityToken', $inst1); } function testInstReturnsSingleton() { @@ -111,7 +111,7 @@ class SecurityTokenTest extends SapphireTest { $t->updateFieldSet($fs); $f = $fs->dataFieldByName($t->getName()); - $this->assertType('HiddenField', $f); + $this->assertInstanceOf('HiddenField', $f); $this->assertEquals($f->getName(), $t->getName(), 'Name matches'); $this->assertEquals($f->Value(), $t->getValue(), 'Value matches'); } @@ -123,7 +123,7 @@ class SecurityTokenTest extends SapphireTest { $t->updateFieldSet($fs); // second $f = $fs->dataFieldByName($t->getName()); - $this->assertType('HiddenField', $f); + $this->assertInstanceOf('HiddenField', $f); $this->assertEquals(1, $fs->Count()); }