From 2c4bf8dacff87a1918c4f34d97bbdaff0a6b3f07 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 2 Feb 2011 23:08:43 +0100 Subject: make unittests run with phpunit 3.5.x --- tests/AllTests.php | 3 --- tests/TestBase.php | 4 ---- tests/TestBaseApi.php | 4 ---- 3 files changed, 11 deletions(-) (limited to 'tests') diff --git a/tests/AllTests.php b/tests/AllTests.php index ded6824..4afcc6b 100644 --- a/tests/AllTests.php +++ b/tests/AllTests.php @@ -17,9 +17,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) { } require_once 'prepare.php'; -require_once 'PHPUnit/Framework/TestSuite.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); /** * SemanticScuttle unit tests. diff --git a/tests/TestBase.php b/tests/TestBase.php index 402330b..8c1a934 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -11,10 +11,6 @@ * @link http://sourceforge.net/projects/semanticscuttle */ -require_once 'PHPUnit/Framework.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - /** * Base unittest class that provides several helper methods. * diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index eb1457f..dacdecd 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -11,10 +11,6 @@ * @link http://sourceforge.net/projects/semanticscuttle */ -require_once 'PHPUnit/Framework.php'; - -PHPUnit_Util_Filter::addFileToFilter(__FILE__); - /** * Base unittest class for web API tests. * -- cgit v1.2.3-54-g00ecf From 4cc46f268676d8df88ce6003df2a7bc9249fe7fb Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 18 Feb 2011 08:01:18 +0100 Subject: get rid of phpunits warnings about deprecated assertType usages --- tests/Bookmark2TagTest.php | 12 ++++++------ tests/BookmarkTest.php | 20 ++++++++++---------- tests/UserTest.php | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php index e6aaf1d..1823c60 100644 --- a/tests/Bookmark2TagTest.php +++ b/tests/Bookmark2TagTest.php @@ -120,7 +120,7 @@ class Bookmark2TagTest extends TestBase $this->b2ts->attachTags($bid, array('foo', 'bar', 'fuu')); $tags = $this->b2ts->getTagsForBookmark($bid); - $this->assertType('array', $tags); + $this->assertInternalType('array', $tags); $this->assertContains('foo', $tags); $this->assertContains('bar', $tags); $this->assertContains('fuu', $tags); @@ -141,10 +141,10 @@ class Bookmark2TagTest extends TestBase $alltags = $this->b2ts->getTagsForBookmarks( array($bid1, $bid2) ); - $this->assertType('array', $alltags); + $this->assertInternalType('array', $alltags); $this->assertEquals(2, count($alltags)); - $this->assertType('array', $alltags[$bid1]); - $this->assertType('array', $alltags[$bid2]); + $this->assertInternalType('array', $alltags[$bid1]); + $this->assertInternalType('array', $alltags[$bid2]); $this->assertEquals(0, count($alltags[$bid1])); $this->assertEquals(0, count($alltags[$bid2])); } @@ -179,9 +179,9 @@ class Bookmark2TagTest extends TestBase $alltags = $this->b2ts->getTagsForBookmarks( array($bid1, $bid2, $bid3, $bid4) ); - $this->assertType('array', $alltags); + $this->assertInternalType('array', $alltags); foreach ($alltags as $bid => $btags) { - $this->assertType('array', $btags); + $this->assertInternalType('array', $btags); if ($bid == $bid1) { $this->assertEquals(3, count($btags)); $this->assertContains('foo', $btags); diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index 2a7c318..f54fe9a 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -263,7 +263,7 @@ class BookmarkTest extends TestBase $bookmark = $this->bs->getBookmark($bid); $ret = $this->bs->bookmarksExist(array($bookmark['bAddress'])); - $this->assertType('array', $ret); + $this->assertInternalType('array', $ret); $this->assertEquals(1, count($ret)); $this->assertTrue($ret[$bookmark['bAddress']]); } @@ -291,7 +291,7 @@ class BookmarkTest extends TestBase $bookmark2['bAddress'] ) ); - $this->assertType('array', $ret); + $this->assertInternalType('array', $ret); $this->assertEquals(2, count($ret)); $this->assertTrue($ret[$bookmark['bAddress']]); $this->assertTrue($ret[$bookmark2['bAddress']]); @@ -308,7 +308,7 @@ class BookmarkTest extends TestBase public function testBookmarksExistFalseSingle() { $ret = $this->bs->bookmarksExist(array('does-not-exist')); - $this->assertType('array', $ret); + $this->assertInternalType('array', $ret); $this->assertEquals(1, count($ret)); $this->assertFalse($ret['does-not-exist']); } @@ -329,7 +329,7 @@ class BookmarkTest extends TestBase 'does-not-exist-3', ); $ret = $this->bs->bookmarksExist($bms); - $this->assertType('array', $ret); + $this->assertInternalType('array', $ret); $this->assertEquals(3, count($ret)); $this->assertFalse($ret['does-not-exist']); $this->assertFalse($ret['does-not-exist-2']); @@ -366,7 +366,7 @@ class BookmarkTest extends TestBase 'does-not-exist-3' ) ); - $this->assertType('array', $ret); + $this->assertInternalType('array', $ret); $this->assertEquals(5, count($ret)); $this->assertTrue($ret[$bookmark['bAddress']]); $this->assertTrue($ret[$bookmark2['bAddress']]); @@ -475,7 +475,7 @@ class BookmarkTest extends TestBase foreach ($bms['bookmarks'] as $bm) { $this->assertArrayHasKey('tags', $bm); - $this->assertType('array', $bm['tags']); + $this->assertInternalType('array', $bm['tags']); if ($bm['bId'] == $bid) { $this->assertContains('foo', $bm['tags']); $this->assertContains('bar', $bm['tags']); @@ -756,7 +756,7 @@ class BookmarkTest extends TestBase $bm = $this->bs->getBookmark($bid, true); $this->assertArrayHasKey('tags', $bm); - $this->assertType('array', $bm['tags']); + $this->assertInternalType('array', $bm['tags']); $this->assertContains('foo', $bm['tags']); $this->assertContains('bar', $bm['tags']); } @@ -874,7 +874,7 @@ class BookmarkTest extends TestBase $bid = $this->addBookmark($uid, $url); $bm = $this->bs->getBookmarkByAddress($url); - $this->assertType('array', $bm); + $this->assertInternalType('array', $bm); $this->assertEquals($url, $bm['bAddress']); } @@ -900,7 +900,7 @@ class BookmarkTest extends TestBase $bid = $this->addBookmark($uid, $url); $bm = $this->bs->getBookmarkByAddress($incomplete); - $this->assertType('array', $bm); + $this->assertInternalType('array', $bm); $this->assertEquals($url, $bm['bAddress']); } @@ -951,7 +951,7 @@ class BookmarkTest extends TestBase $this->assertEquals('new description', $bm['bDescription']); $this->assertEquals('new private note', $bm['bPrivateNote']); $this->assertEquals(1, $bm['bStatus']); - $this->assertType('array', $bm['tags']); + $this->assertInternalType('array', $bm['tags']); $this->assertEquals(1, count($bm['tags'])); $this->assertContains('new', $bm['tags']); } diff --git a/tests/UserTest.php b/tests/UserTest.php index 6da7776..49f3730 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -143,7 +143,7 @@ class UserTest extends TestBase $uid = $this->addUser(); $users = $this->us->getObjectUsers(); $this->assertEquals(1, count($users)); - $this->assertType('SemanticScuttle_Model_User', reset($users)); + $this->assertInstanceOf('SemanticScuttle_Model_User', reset($users)); } @@ -160,7 +160,7 @@ class UserTest extends TestBase $uid3 = $this->addUser(); $users = $this->us->getObjectUsers(); $this->assertEquals(3, count($users)); - $this->assertType('SemanticScuttle_Model_User', reset($users)); + $this->assertInstanceOf('SemanticScuttle_Model_User', reset($users)); } -- cgit v1.2.3-54-g00ecf From 975809a8347929c9eae9c6a8bf3beb8d92af63ef Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 15 Mar 2011 19:18:57 +0100 Subject: unit test for the new SemanticScuttle_Model_UserArray class --- tests/UserArrayTest.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/UserArrayTest.php (limited to 'tests') diff --git a/tests/UserArrayTest.php b/tests/UserArrayTest.php new file mode 100644 index 0000000..cb53f15 --- /dev/null +++ b/tests/UserArrayTest.php @@ -0,0 +1,68 @@ + + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ + +require_once 'prepare.php'; + +/** + * Unit tests for the SemanticScuttle user array model. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class UserArrayTest extends PHPUnit_Framework_TestCase +{ + + public function testGetNameLongName() + { + $this->assertEquals( + 'John Doe', + SemanticScuttle_Model_UserArray::getName( + array( + 'name' => 'John Doe', + 'username' => 'jdoe' + ) + ) + ); + } + + public function testGetNameUsernameIfNameIsEmpty() + { + $this->assertEquals( + 'jdoe', + SemanticScuttle_Model_UserArray::getName( + array( + 'name' => '', + 'username' => 'jdoe' + ) + ) + ); + } + + public function testGetNameUsernameIfNameIsNotSet() + { + $this->assertEquals( + 'jdoe', + SemanticScuttle_Model_UserArray::getName( + array( + 'username' => 'jdoe' + ) + ) + ); + } + +} + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf