Skip to content

Instantly share code, notes, and snippets.

@netraagal
Last active April 9, 2018 08:49
Show Gist options
  • Save netraagal/c5becc91e20d2f513d4e723cdaf2ecd8 to your computer and use it in GitHub Desktop.
Save netraagal/c5becc91e20d2f513d4e723cdaf2ecd8 to your computer and use it in GitHub Desktop.
Behat, MinkExtension - order your functions

Use of Traits in Php

Here, traits allows to order the functions according to the categories you choose (as for me, what they do).

Even if you don't have many of functions, it's became really usefull (+gain of time) at the end. Because, after a little while, it can be really annoying to scroll beetwing functions.

And it appears more clean to have functions disposed and sorted in files.

<?php
/**
* @author netraagal
*/
namespace App\Dictionary;
trait AssertDictionary
{
//functions in my other gist AssertFeatureContext.php
}
<?php
/**
* @author netraagal
*/
namespace App\Features;
use App\Dictionary\TimerDictionary;
use App\Dictionary\AssertDictionary;
use App\Dictionary\GetElementDictionary;
use App\Dictionary\WindowDictionary;
class FeatureContext extends MinkContext implements SnippetAcceptingContext
{
use TimerDictionary;
use AssertDictionary;
use GetElementDictionary;
use WindowDictionary;
}
<?php
/**
* @author netraagal
*/
namespace App\Dictionary;
trait GetElementDictionary
{
//functions in my other gist GetElementFeatureContext.php
}
<?php
/**
* @author netraagal
*/
namespace App\Dictionary;
trait TimerDictionary
{
//functions in my other gist TimerFeatureContext.php
}
<?php
/**
* @author netraagal
*/
namespace App\Dictionary;
trait WindowDictionary
{
//functions in my other gist WindowFeatureContext.php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment