-
-
Save kdocki/3273e52a64cb3da32413 to your computer and use it in GitHub Desktop.
The base scenario class I created for helping me with scenarios in Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class BaseScenario | |
{ | |
/** | |
* This controller is told what to do by our scenario | |
*/ | |
public $controller = null; | |
/** | |
* [__construct description] | |
* @param [type] $input [description] | |
*/ | |
public function __construct(Input $input = null) | |
{ | |
$this->input = $input ?: App::make('Input'); | |
} | |
/** | |
* Create a new validator instance for us | |
* | |
* @param [type] $input [description] | |
* @param [type] $rules [description] | |
* @param [type] $messages [description] | |
* @return [type] [description] | |
*/ | |
protected function validator($input, $rules, $messages = []) | |
{ | |
return Validator::make($input, $rules, $messages); | |
} | |
/** | |
* Calls protected/public methods on a class for us | |
* | |
* @param [type] $class [description] | |
* @param [type] $method [description] | |
* @return [type] [description] | |
*/ | |
protected function invoke($methodName, $args) | |
{ | |
$obj = $this->controller; | |
$method = new ReflectionMethod(get_class($obj), $methodName); | |
$method->setAccessible(true); | |
return $method->invokeArgs($obj, $args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment