Skip to content

Instantly share code, notes, and snippets.

@kdocki
Created November 17, 2013 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kdocki/3273e52a64cb3da32413 to your computer and use it in GitHub Desktop.
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
<?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