Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Add unit tests #4

Closed
aik099 opened this issue Dec 1, 2013 · 13 comments
Closed

Add unit tests #4

aik099 opened this issue Dec 1, 2013 · 13 comments

Comments

@aik099
Copy link
Member

aik099 commented Dec 1, 2013

Right now there are no unit tests or Travis CI integration, which makes it pretty hard to safely make changes to the driver code.

@patrickdreyer can you please add tests (I'm guessing this will be similar to ones, done in MinkGoutteDriver, where MinkBrowserKitDriver tests are executed).

@aik099
Copy link
Member Author

aik099 commented Dec 1, 2013

I've tried to add following test:

class WUnitDriverTest extends HeadlessDriverTest
{
    protected static function getDriver()
    {
        \Yii::setApplication(\WUnit\WUnit::createWebApplication());

        return new WUnitDriver();
    }
}

This didn't work. I've figured out, that I need some kind of Yii application that would represent website with web fixtures. Also I've added dependency to Yii framework in composer.json, since otherwise I've just got missing classes error.

@patrickdreyer
Copy link
Contributor

The only unit test would be for testing the constructor.
Everything else would test either the base class or the underlying Client or HttpKernelInterface implementation, YiiKernel in this case.
Or am I missing something here

@aik099
Copy link
Member Author

aik099 commented Dec 2, 2013

Same as MinkGoutteDriver. We're just testing, that used Client class really does fetch pages and do MinkBrowserKitDriver operations on them.

Besides, does it curl pages as Goutte driver or not?

@patrickdreyer
Copy link
Contributor

No, it's one step further to having a headless browser emulator, as it DIRECTLY calls the Yii application.
As you can see, WUnit::createClient() initializes the HttpKernel\Client instance with the HttpKernelInterface implementation YiiKernel.
YiiKernel first fetches the Yii application \Yii::app() and calls DIRECTLY it's processRequest() method.
You may do rich and non rich UI testing in one Behat run.
Simply tag your rich UI test scenarios with @javascript or @mink:selenium2 as explained on http://docs.behat.org/cookbook/behat_and_mink.html#test-in-browser-selenium2-session

@patrickdreyer
Copy link
Contributor

Yii framework should only be a dependency for testing, otherwise we'll sure have conflicts. This as most users probably still do NOT install Yii the composer way (like myself), thus they end up with a directory structure like:

my-application (Yii installation goes here)
-+------------
 +-- framework
 +-- protected
 |   -+-------
 |    +-- ...
 |    +-- tests
 |    |   -+---
 |    |    +-- bin
 |    |    +-- ...
 |    |    +-- vendor (here go the composer downloads)
 |    |    +-- bootstrap.php
 |    |    +-- composer.json
 |    |    +-- ...
 |    +-- ...
 +-- themes
 +-- .htaccess
 +-- index.php

Having Yii as MinkWUnitDriver dependency by default would end up in having Yii present twice.

@aik099
Copy link
Member Author

aik099 commented Feb 25, 2014

As dev dependency only of course. If you're willing to add missing tests, then you're welcome.

@patrickdreyer
Copy link
Contributor

Looking at https://github.com/weavora/wunit guys, they already have quite some tests.
Let me get in contact with those guys.
The final goal is:

  • make weavora/wunit composer aware
  • remove the whole WUnit stuff from this repository
  • depend this repository from weavora/wunit

This way the testing is covered by the weavora/wunit repo.
However, we for sure don't wanna maintain a copy of them.

@stof
Copy link
Member

stof commented Feb 25, 2014

See weavora/wunit#12 for the first point.

However, this package seems quite unmaintained. Except for a few readme changes, the last update was 2 years ago

@patrickdreyer
Copy link
Contributor

You are right, and I just saw that I already placed an Issue there about getting the package composer ready - no answer so far.
Probably better to start a fork under Behat/WUnit and then apply the steps in my last comment.

@stof
Copy link
Member

stof commented Feb 25, 2014

@patrickdreyer I don't think it makes sense to maintain WUnit in its own repo in the Behat organization. It is something specific to Yii, which is not used by any of the core team AFAIK (I might be wrong here though). Either a maintained version of WUnit with proper composer support appears in another orga (or on a personal account for that matter), or I suggest keeping the code inside the driver repo itself.

@patrickdreyer
Copy link
Contributor

Thanks for your thoughts @stof.
This leads me to:

  • place an issue at weavora/wunit what we are up to - just in case
  • Copy&Paste the tests from weavora/wunit
  • Check if Yii dependency is required for testing; most probably yes as the fixtures include a whole bunch of Yii related stuff
  • adapt the tests due to refactored YiiRequest
  • get the tests running
  • place an issue in weavora/wunit that we are running
  • release version 1.0.0

@stof
Copy link
Member

stof commented Jan 12, 2015

@patrickdreyer do you have any news about the composer support in WUnit itself to relu on their package rather than duplicating it ?

@stof
Copy link
Member

stof commented Jan 12, 2015

I created a separate issue to discuss about running the driver testsuite as this discussion is talking about the tests for WUnit itself: #9

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants