Behat / YiiExtension

Yii framework integration extension for Behat
MIT License
27 stars 8 forks source link

Adding wunit support #8

Closed patrickdreyer closed 10 years ago

patrickdreyer commented 11 years ago

Added the wunit session and have it loaded by the extension if mink_driver is set to true. Adapted the yii extension to look like the mink extension.

@stof: Considered your comment about class checking in my pull request #7.

patrickdreyer commented 11 years ago

@stof I removed the mink_driver parameter and only left the wunit one. As we don't wanna force the usage of wunit, it shall remain disabled by default.

Additionally, I added the support for redirects using wunit. For this to work, we need to intercept any calls to CApplication.end() to properly handle it. This is all taken care of by the MinkWUnitDriver extension. However, for YiiExtension creating the correct application, we need to tweak it a little.

stof commented 11 years ago

@patrickdreyer I think the parmaeter should stay named mink_driver (for consistency with the Symfony extension and because it is clearer IMO). If you don't enable the MinkWUnitDriver in the extension, you will not need to use WUnit as it is used only by the driver.

patrickdreyer commented 10 years ago

@stof I assume the pull request is now fine with the changes on the wunit node definition.

stof commented 10 years ago

I still think this setting should be named mink_driver (or mink_session as it technically registers a session). It is a better description of what this node is doing

patrickdreyer commented 10 years ago

By using canBeUnset() we satisfy both expectations, either one uses wunit: true or wunit: ~ for activating the WUnit driver. Please have a look at http://docs.behat.org/cookbook/behat_and_mink.html#installing-mink about how to activate the Mink drivers Goutte and Selenium2. An extension providing additional Mink drivers is expected to behave just the same as the Mink extension itself, thus to activate a driver one simply uses the syntax <driver name>: ~. Let's make an example for activating goutte, selenium2, symfony2 and wunit, making wunit the default session:

# behat.yml
default:
    extensions:
        Behat\MinkExtension\Extension:
            goutte: ~
            selenium2: ~
            default_session: wunit
        Behat\Symfony2Extension\Extension:
            mink_driver: true
        Behat\YiiExtension\Extension:
            wunit: ~
            another_mink_driver_tailored_for_Yii: ~

@stof, this is why I do not agree in renaming wunit to mink_driver. Please accept the pull request #8, so that waiting developers #10 can finally get advantage of the WUnit support. Many thanks.

stof commented 10 years ago

@patrickdreyer what could be another driver tailored for Yii ? And wunit: ~does not tell anything about being related to Mink

patrickdreyer commented 10 years ago

@stof please stop playing ping-pong and provide your solution you have in mind. This salami tactic gets one crazy. For now I assume you have the following in mind:

Behat\YiiExtension\Extension:
  mink_driver: true
  wunit: ~

Whereas we can even skip the wunit line altogether, as wunit is the only existing Yii mink driver. Right?

Now, just to make my curiosity happy, what do you have in mind if we get a second Yii mink driver? Please provide an example yml configuration.

stof commented 10 years ago

I always said to name the config key mink_driver instead of naming it wunit.

and what sort of second Yii Mink driver would you get ? anyway, if we ever get such a second driver in the future, its support will be provided for Behat 3/MinkExtension 2, not for Behat 2.5/MinkExtension 1.x, so enabling it would not be done in the config of the YiiExtension anyway.

patrickdreyer commented 10 years ago

Done: wunit -> mink_driver I also added the changed README.md. Let me know if this would screw up this pull request. If so, I will remove it and add it later on.

Thanks for the explanation about additional drivers and that we would treat it different in Behat 3.

patrickdreyer commented 10 years ago

@stof please note, the whole README.md is a copy&paste from the latest version. I don't wanna change any content except the wunit -> mink_driver stuff right now. Nevertheless, your points are all valid and I happily addressed them immediately afterwards. If you don't agree, I simply remove README.md, but then the latest README.md will stay wrong. Did you get the point?

stof commented 10 years ago

if the whole readme is a copy-paste, why does it appear as a new file ?

patrickdreyer commented 10 years ago

I was an absolute newbie regarding github when I started working on all this. Thus, I added the README independent of my separate fork branch for adding the wunit support :-( If this is confusing, let's get the README file out for know and I change it right after.

stof commented 10 years ago

@everzet I don't have access to this repo (probably the only one of the organization in this case). Can you add it the repo I can write to ?

stof commented 10 years ago

OK, I understood why this happens: your branch was created before the readme was added in the repo. I have rebased the branch locally to have a clean commit in the history of the readme instead of a conflicting copy-paste. Thanks for this.

stof commented 10 years ago

I updated the extension to rely on Behat 2.5 rather than 2.4.

I'm not a Yii user. Tell me if it works fine for you. If it does, I suggest tagging the extension as 1.0.

patrickdreyer commented 10 years ago

Looks like you can read my mind. Will do and update whatever required (e.g. readme), but most probably not before next week.

patrickdreyer commented 10 years ago

Rely on Behat 2.5 looks good, go may ahead for tagging 1.0.