? No Code Attached Yet J3 Issue
avatar mbabker
mbabker
11 Feb 2019

Within Joomla's test suites (both the CMS and Framework), PHPUnit's DbUnit extension is used heavily for test scenarios that involve database interaction. Sebastian has deprecated the DbUnit extension as it is a common practice in the PHP ecosystem to build a local environment setup process for tests that interact with a database versus using the extension (and using that extension complicates test maintenance a bit because it means you have base classes extending both PHPUnit\Framework\TestCase and PHPUnit_Extensions_Database_TestCase.

All tests within Joomla owned repositories should be refactored to not rely on this deprecated extension.

avatar mbabker mbabker - open - 11 Feb 2019
avatar joomla-cms-bot joomla-cms-bot - change - 11 Feb 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Feb 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 3 Mar 2019
Status New Discussion
avatar franz-wohlkoenig franz-wohlkoenig - change - 28 Mar 2019
Category Unit Tests
avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Apr 2019
Labels Added: J3 Issue
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 4 Apr 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Apr 2019
Labels Added: ?
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 7 Apr 2019
avatar mbabker
mbabker - comment - 22 May 2019

Nevermind, seems the test focus is on infrastructure instead of the actual tests.

avatar mbabker mbabker - close - 22 May 2019
avatar mbabker mbabker - change - 22 May 2019
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2019-05-22 12:18:33
Closed_By mbabker
avatar HLeithner
HLeithner - comment - 22 May 2019

if the infrastructure doesn't work as it should, and that's a topic we are working on, it hard to upgrade the tests.
@Hackwar if you have time could you look at this?

avatar HLeithner HLeithner - change - 22 May 2019
Status Closed New
Closed_Date 2019-05-22 12:18:33
Closed_By mbabker
avatar HLeithner HLeithner - reopen - 22 May 2019
avatar Hackwar
Hackwar - comment - 22 May 2019

I'm actually working on exactly that right now. The unit tests don't work with the database anyway and we currently have no integration tests in our testing setup. With that being the case for nearly 2 years, the old tests of 3.x are pretty much useless right now and thus we have to start over anyway. So I'm looking into how to setup these integration tests properly. Hopefully in the next few days.

avatar franz-wohlkoenig franz-wohlkoenig - change - 23 May 2019
Status New Discussion
avatar mbabker
mbabker - comment - 18 Jun 2019

In the hopes that nobody decides to re-invent the wheel yet again (doubtful), I have extracted the DatabaseTestCase I am using for the stats server into the Framework's Test package and updated its master branch for the Framework 2.0 requirements. The relevant bits are the DatabaseTestCase and the DatabaseManager with some of the high level functions that would be needed in basic tests interfacing with a database. Do what you want for the CMS, but since depending on DbUnit is a blocker for upgrading to PHPUnit 8 I'm using that code in the Framework package tests.

avatar HLeithner
HLeithner - comment - 18 Jun 2019

Do what you want for the CMS, but since depending on DbUnit is a blocker for upgrading to PHPUnit 8 I'm using that code in the Framework package tests.

Any example how to convert or use the dbunit code to the testing package? You extracted it from the statistic server the relevant commit is joomla/statistics-server@7cb7ba8 ?
I didn't looked at dbunit but should the replacement straight forward?

avatar mbabker
mbabker - comment - 18 Jun 2019

It's not a 1-for-1 swap unfortunately, nor am I trying to write a DbUnit replacement.

Right now the DatabaseManager only has logic for a few high level operations:

  • Create a database
  • Drop a database
  • Truncate all tables in a database

Between the CMS and the various Framework apps floating around out there, there are a lot of differing database schemas and differing ways to manage seeding a database (the Joomla\CMS\Schema library for the CMS, or the Joomla\StatsServer\Database\Migrations class for the stats server app, or the use of Phinx in the Framework website app). So the manager doesn't have anything to explicitly load a schema, the extended DatabaseManager in the stats server app has some code to help with getting the database schema loaded and dropping in some test data for cases that need it (demonstrating the whole "extend this to add your app specific logic" bit).

The DatabaseTestCase right now basically makes sure the database is in a clean state before starting the tests for a class (dropping the test database if it already exists, then creating it) and cleaning up after that class' tests are done (dropping the database). If you need to load schema or anything, you need to do that in your extended classes.

Note right now this is only practically tested on MySQL as that's what the stats server is running. Once the Framework's Authentication and Session package tests get updated to use this newer code, should be able to work out what kind of issues may exist and adapt the test case and manager as needed.

The intent really is to keep those base classes as the high level logic needed to manage params and manage the database state, it's not intended to be as fully featured as DbUnit because there is a lot of app specific logic that needs to exist in a base database test case that DbUnit couldn't cover.

avatar HLeithner
HLeithner - comment - 18 Jun 2019

ok thx for the explanation.

avatar brianteeman
brianteeman - comment - 23 Aug 2022

As far as I can tell this issue has been addressed and dbuint is no longer used.

@Hackwar if you can confirm please then this can be closed

avatar rdeutz rdeutz - change - 23 Aug 2022
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2022-08-23 17:36:59
Closed_By rdeutz
Labels Added: ? No Code Attached Yet
Removed: ?
avatar rdeutz rdeutz - close - 23 Aug 2022
avatar rdeutz
rdeutz - comment - 23 Aug 2022

It's addressed for 4

avatar brianteeman
brianteeman - comment - 23 Aug 2022

Thanks for confirming @rdeutz

Add a Comment

Login with GitHub to post a comment