Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some improvements in tests #5: #13410

Merged
merged 1 commit into from
Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,18 @@ public function testForEach($select, $from, $column, $class, $limit, $offset, $e
public function testCount()
{
self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'));
$this->assertEquals(
4,
count(self::$driver->getIterator())
$this->assertCount(
4, self::$driver->getIterator()
);

self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 0, 2);
$this->assertEquals(
2,
count(self::$driver->getIterator())
$this->assertCount(
2, self::$driver->getIterator()
);

self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 3, 2);
$this->assertEquals(
1,
count(self::$driver->getIterator())
$this->assertCount(
1, self::$driver->getIterator()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,18 @@ public function testForEach($select, $from, $column, $class, $limit, $offset, $e
public function testCount()
{
self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'));
$this->assertEquals(
4,
count(self::$driver->getIterator())
$this->assertCount(
4, self::$driver->getIterator()
);

self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 0, 2);
$this->assertEquals(
2,
count(self::$driver->getIterator())
$this->assertCount(
2, self::$driver->getIterator()
);

self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 3, 2);
$this->assertEquals(
1,
count(self::$driver->getIterator())
$this->assertCount(
1, self::$driver->getIterator()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testConstruct()
$object = new JComponentRouterBaseInspector($app2);
$this->assertEquals($app2, $object->app);
//The original $app is not the same object as $app2, thus we did not use JFactory
$this->assertFalse($app === $object->app);
$this->assertNotSame($app, $object->app);

/**
* Test if the setup works when both an app and menu object is handed over
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/suites/libraries/cms/module/JModuleHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ public function testGetModules()
{
$modules = JModuleHelper::getModules('position-0');

$this->assertEquals(
count($modules),
1,
'There is 1 module in position-0'
);
$this->assertCount(1, $modules, 'There is 1 module in position-0');

$this->assertEquals(
$modules[0]->id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testGetPluginGroup()
{
$plugins = JPluginHelper::getPlugin('content');
$this->assertInternalType('array', $plugins, 'Method should return all plugins in a group');
$this->assertEquals(7, count($plugins), 'Method should return all plugins in a group');
$this->assertCount(7, $plugins, 'Method should return all plugins in a group');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function test__constructDependancyInjection()
public function testClose()
{
// Make sure the application is not already closed.
$this->assertSame($this->class->closed, null);
$this->assertNull($this->class->closed);

$this->class->close(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function testClearHeaders()
public function testClose()
{
// Make sure the application is not already closed.
$this->assertSame($this->class->closed, null);
$this->assertNull($this->class->closed);

$this->class->close(3);

Expand Down
10 changes: 4 additions & 6 deletions tests/unit/suites/libraries/joomla/cache/JCacheConstructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ public function testConstruct($type)
{
$class = 'JCacheController' . ucfirst($type);
$cache = JCache::getInstance($type);
$this->assertTrue(
($cache instanceof $class),
'Expecting= ' . $class . ' Returned= ' . get_class($cache)
$this->assertInstanceOf(
$class, $cache, 'Expecting= ' . $class . ' Returned= ' . get_class($cache)
);
$cache2 = JCache::getInstance($type);
$this->assertTrue(
($cache !== $cache2),
'Type: ' . $type . ' received the same instance twice'
$this->assertNotSame(
$cache, $cache2, 'Type: ' . $type . ' received the same instance twice'
);
}
}
2 changes: 1 addition & 1 deletion tests/unit/suites/libraries/joomla/cache/JCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public function testGc()
// Collect Garbage
$this->object->gc();

$this->assertFalse(file_exists($path), "Cache file should not exist.");
$this->assertFileNotExists($path, "Cache file should not exist.");

$this->assertFalse($this->object->get(42, ''));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ public function test__clone_array()

$baseElement->testArray[] = 'a';

$this->assertFalse($baseElement === $cloneElement);
$this->assertEquals(count($cloneElement->testArray), 0);
$this->assertNotSame($baseElement, $cloneElement);
$this->assertCount(0, $cloneElement->testArray);
}

/**
Expand All @@ -263,7 +263,7 @@ public function test__clone_object()

$cloneElement = clone($baseElement);

$this->assertFalse($baseElement === $cloneElement);
$this->assertFalse($baseElement->testObject === $cloneElement->testObject);
$this->assertNotSame($baseElement, $cloneElement);
$this->assertNotSame($baseElement->testObject, $cloneElement->testObject);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1642,8 +1642,8 @@ public function test__clone_array()

$baseElement->testArray[] = 'test';

$this->assertFalse($baseElement === $cloneElement);
$this->assertTrue(count($cloneElement->testArray) == 0);
$this->assertNotSame($baseElement, $cloneElement);
$this->assertCount(0, $cloneElement->testArray);
}

/**
Expand All @@ -1661,9 +1661,9 @@ public function test__clone_object()

$cloneElement = clone($baseElement);

$this->assertFalse($baseElement === $cloneElement);
$this->assertNotSame($baseElement, $cloneElement);

$this->assertFalse($baseElement->testObject === $cloneElement->testObject);
$this->assertNotSame($baseElement->testObject, $cloneElement->testObject);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/suites/libraries/joomla/feed/JFeedEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testMagicSetUpdatedDateJDateObject()
$properties = TestReflection::getValue($this->_instance, 'properties');

$this->assertInstanceOf('JDate', $properties['updatedDate']);
$this->assertTrue($date === $properties['updatedDate']);
$this->assertSame($date, $properties['updatedDate']);
}

/**
Expand All @@ -102,7 +102,7 @@ public function testMagicSetAuthorWithPerson()
$properties = TestReflection::getValue($this->_instance, 'properties');

$this->assertInstanceOf('JFeedPerson', $properties['author']);
$this->assertTrue($person === $properties['author']);
$this->assertSame($person, $properties['author']);
}

/**
Expand Down Expand Up @@ -202,7 +202,7 @@ public function testAddContributor()
$properties = TestReflection::getValue($this->_instance, 'properties');

// Make sure we aren't adding the same contributor more than once.
$this->assertTrue(count($properties['contributors']) == 1);
$this->assertCount(1, $properties['contributors']);
}

/**
Expand Down Expand Up @@ -232,7 +232,7 @@ public function testAddLink()
$properties = TestReflection::getValue($this->_instance, 'properties');

// Make sure we aren't adding the same link more than once.
$this->assertTrue(count($properties['links']) == 1);
$this->assertCount(1, $properties['links']);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/suites/libraries/joomla/feed/JFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testMagicSetUpdatedDateJDateObject()
$properties = TestReflection::getValue($this->_instance, 'properties');

$this->assertInstanceOf('JDate', $properties['updatedDate']);
$this->assertTrue($date === $properties['updatedDate']);
$this->assertSame($date, $properties['updatedDate']);
}

/**
Expand All @@ -102,7 +102,7 @@ public function testMagicSetAuthorWithPerson()
$properties = TestReflection::getValue($this->_instance, 'properties');

$this->assertInstanceOf('JFeedPerson', $properties['author']);
$this->assertTrue($person === $properties['author']);
$this->assertSame($person, $properties['author']);
}

/**
Expand Down Expand Up @@ -189,7 +189,7 @@ public function testAddContributor()
$properties = TestReflection::getValue($this->_instance, 'properties');

// Make sure we aren't adding the same contributor more than once.
$this->assertTrue(count($properties['contributors']) == 1);
$this->assertCount(1, $properties['contributors']);
}

/**
Expand Down Expand Up @@ -217,7 +217,7 @@ public function testAddEntry()
$entries = TestReflection::getValue($this->_instance, 'entries');

// Make sure we aren't adding the same entry more than once.
$this->assertTrue(count($entries) == 1);
$this->assertCount(1, $entries);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,19 +506,19 @@ public function testProcessFeedEntry()

TestReflection::invoke($this->_instance, 'processFeedEntry', $entry, $el);

$this->assertEquals('http://example.com/id', $entry->uri);
$this->assertEquals('title', $entry->title);
$this->assertSame('http://example.com/id', $entry->uri);
$this->assertSame('title', $entry->title);
$this->assertInstanceOf('JDate', $entry->updatedDate);
$this->assertInstanceOf('JDate', $entry->publishedDate);
$this->assertEquals('description', $entry->content);
$this->assertEquals(array('category' => ''), $entry->categories);
$this->assertSame('description', $entry->content);
$this->assertSame(array('category' => ''), $entry->categories);
$this->assertInstanceOf('JFeedPerson', $entry->author);
$this->assertEquals('Webmaster', $entry->author->name);
$this->assertEquals('admin@domain.com', $entry->author->email);
$this->assertEquals(1, count($entry->links));
$this->assertSame('Webmaster', $entry->author->name);
$this->assertSame('admin@domain.com', $entry->author->email);
$this->assertCount(1, $entry->links);
$this->assertInstanceOf('JFeedLink', $entry->links[0]);
$this->assertEquals('http://www.w3schools.com/media/3d.wmv', $entry->links[0]->uri);
$this->assertEquals('video/wmv', $entry->links[0]->type);
$this->assertSame('http://www.w3schools.com/media/3d.wmv', $entry->links[0]->uri);
$this->assertSame('video/wmv', $entry->links[0]->type);
$this->assertEquals(78645, $entry->links[0]->length);
}

Expand All @@ -540,8 +540,8 @@ public function testProcessPerson($input, $name, $email)

$this->assertInstanceOf('JFeedPerson', $person);

$this->assertEquals($name, $person->name);
$this->assertEquals($email, $person->email);
$this->assertSame($name, $person->name);
$this->assertSame($email, $person->email);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public function testListPhotos()
$this->http->expects($this->once())->method('get')->will($this->returnCallback('picasaPhotolistCallback'));
$results = $this->object->listPhotos();

$this->assertEquals(count($results), 2);
$this->assertCount(2, $results);
$i = 1;

foreach ($results as $result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function testListAlbums()
$this->http->expects($this->once())->method('get')->will($this->returnCallback('picasaAlbumlistCallback'));
$results = $this->object->listAlbums('userID');

$this->assertEquals(count($results), 2);
$this->assertCount(2, $results);
$i = 1;

foreach ($results as $result)
Expand Down
Loading