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

Add unit tests for JInstallerAdapter #7569

Merged
merged 11 commits into from
Sep 8, 2015
Merged

Conversation

wilsonge
Copy link
Contributor

This gives us code coverage of ~75% of the lines in the class (15/23 methods in the class)

$mockDatabase = $this->getMockDatabase();
$object = $this->getMockForAbstractClass('JInstallerAdapter', array($mockInstaller, $mockDatabase, array('foo' => 'bar')));

$this->assertInstanceOf(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->assertAttributeInstanceOf('JTableExtension', 'extension', $object);

Don't need to use our Reflection helpers here. Use the PHPUnit API as it's practical.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and a couple of other instances based on this

* @subpackage Installer
* @since 3.4.4
*/
class JInstallerAdapterTest extends TestCaseDatabase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you've mocked everything and you aren't running any real database queries (still looking this over), then you can just extend TestCase instead. Saves a few processing cycles on the test setup if it doesn't have to deal with the database configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK So my dataset still isn't being loaded :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop overriding JFactory::$database in your setup method. TestCaseDatabase is setting the test connection in its setup routine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh fair. Does this mean I don't need to inject the extensions data set as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long and short, just make sure all the changes from wilsonge@6ab866e are reverted and we can go from there.

@mbabker
Copy link
Contributor

mbabker commented Jul 28, 2015

Can you put @covers tags on all the test methods please?

@wilsonge
Copy link
Contributor Author

Done everything I think

@mbabker
Copy link
Contributor

mbabker commented Jul 28, 2015

Well, the question was answered on the database thing. Guess it needs to extend TestCaseDatabase.

@wilsonge
Copy link
Contributor Author

I'm going to try mocking the JFactory::$database in the constructor. That might be enough. If not I'll revert it back to the way it was

@wilsonge
Copy link
Contributor Author

wilsonge commented Sep 8, 2015

@mbabker where we at with this?

mbabker added a commit that referenced this pull request Sep 8, 2015
Add unit tests for JInstallerAdapter
@mbabker mbabker merged commit a433677 into joomla:staging Sep 8, 2015
@wilsonge wilsonge deleted the installertests branch September 8, 2015 23:37
@zero-24 zero-24 added this to the Joomla! 3.4.5 milestone Sep 9, 2015
@zero-24 zero-24 modified the milestones: Joomla! 3.4.6, Joomla! 3.5.0 Oct 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants