Hoa central
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Praspel\AssertionChecker\AssertionChecker Class Reference
Inheritance diagram for Hoa\Praspel\AssertionChecker\AssertionChecker:

Public Member Functions

 __construct (Praspel\Model\Specification $specification, Core\Consistency\Xcallable $callable, $generateData=false)
 
 preamble ($preamble)
 
 evaluate ()
 
 getSpecification ()
 
 automaticallyGenerateData ($generateData)
 
 canGenerateData ()
 
 setData (Array $data)
 
 getData ()
 
 getCallable ()
 

Static Public Member Functions

static generateData (Praspel\Model\Specification $specification)
 

Protected Member Functions

 setSpecification (Praspel\Model\Specification $specification)
 
 setCallable (Core\Consistency\Xcallable $callable)
 
 getVisitorPraspel ()
 

Protected Attributes

 $_specification = null
 
 $_data = null
 
 $_generateData = false
 
 $_callable = null
 

Detailed Description

Class .

Generic assertion checker.

Definition at line 50 of file AssertionChecker.php.

Constructor & Destructor Documentation

Hoa\Praspel\AssertionChecker\AssertionChecker::__construct ( Praspel\Model\Specification  $specification,
Core\Consistency\Xcallable  $callable,
  $generateData = false 
)

Construct.

Parameters
\Hoa\Praspel\Model\Specification$specificationSpecification.
\Hoa\Core\Consistency\Xcallable$callableCallable.
bool$genrateDataGenerate data.
Returns
void

Definition at line 90 of file AssertionChecker.php.

94  {
95  $this->setSpecification($specification);
96  $this->setCallable($callable);
97  $this->automaticallyGenerateData($generateData);
98 
99  return;
100  }
setCallable(Core\Consistency\Xcallable $callable)
setSpecification(Praspel\Model\Specification $specification)

Here is the call graph for this function:

Member Function Documentation

Hoa\Praspel\AssertionChecker\AssertionChecker::automaticallyGenerateData (   $generateData)

Enable or disable the automatic data generation.

Parameters
bool$generateDataGenerate data or not.
Returns
bool

Definition at line 196 of file AssertionChecker.php.

197  {
198  $old = $this->_generateData;
199  $this->_generateData = $generateData;
200 
201  return $old;
202  }

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::canGenerateData ( )

Whether we are able to automatically generate data.

Returns
bool

Definition at line 209 of file AssertionChecker.php.

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::evaluate ( )
abstract

Assertion checker.

Returns
bool
Exceptions
static Hoa\Praspel\AssertionChecker\AssertionChecker::generateData ( Praspel\Model\Specification  $specification)
static

Generate data. Isotropic random generation of data from the clause.

Parameters
\Hoa\Praspel\Model\Specification$specificationSpecification.
Returns
array

Definition at line 134 of file AssertionChecker.php.

135  {
136  $data = [];
137  $behavior = $specification;
138 
139  do {
140  if (true === $behavior->clauseExists('requires')) {
141  foreach ($behavior->getClause('requires') as $name => $variable) {
142  $data[$name] = $variable->sample();
143  }
144  }
145 
146  if (false === $behavior->clauseExists('behavior')) {
147  break;
148  }
149 
150  $behaviors = $behavior->getClause('behavior');
151  $count = count($behaviors);
152  $i = mt_rand(0, $count);
153 
154  if ($i === $count) {
155  if (true === $behavior->clauseExists('default')) {
156  $behavior = $behavior->getClause('default');
157  }
158  } else {
159  $behavior = $behaviors->getNth($i);
160  }
161  } while (true);
162 
163  return $data;
164  }
Hoa\Praspel\AssertionChecker\AssertionChecker::getCallable ( )

Get callable.

Returns

Definition at line 257 of file AssertionChecker.php.

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::getData ( )

Get data.

Returns
array

Definition at line 233 of file AssertionChecker.php.

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::getSpecification ( )

Get specification.

Returns

Definition at line 185 of file AssertionChecker.php.

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::getVisitorPraspel ( )
protected

Get visitor Praspel.

Returns

Definition at line 267 of file AssertionChecker.php.

268  {
269  if (null === $this->_visitorPraspel) {
270  $this->_visitorPraspel = new Praspel\Visitor\Praspel();
271  }
272 
273  return $this->_visitorPraspel;
274  }

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::preamble (   $preamble)

Preamble: put the system under test into a specific state in order to be able to execute the test.

Parameters
mixed$preamblePreamble callable.
Returns
void

Definition at line 109 of file AssertionChecker.php.

110  {
111  $preambler = new Praspel\Preambler\Handler($this->getCallable());
112  $preamble($preambler);
113  $this->setCallable($preambler->__getCallable());
114 
115  return;
116  }
setCallable(Core\Consistency\Xcallable $callable)

Here is the call graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::setCallable ( Core\Consistency\Xcallable  $callable)
protected

Set callable.

Parameters
\Hoa\Core\Consistency\Xcallable$callableCallable.
Returns

Definition at line 244 of file AssertionChecker.php.

245  {
246  $old = $this->_callable;
247  $this->_callable = $callable;
248 
249  return $old;
250  }

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::setData ( Array  $data)

Set data.

Parameters
array$dataData.
Returns
array

Definition at line 220 of file AssertionChecker.php.

221  {
222  $old = $this->_data;
223  $this->_data = $data;
224 
225  return $old;
226  }

Here is the caller graph for this function:

Hoa\Praspel\AssertionChecker\AssertionChecker::setSpecification ( Praspel\Model\Specification  $specification)
protected

Set specification.

Parameters
\Hoa\Praspel\Model\Specification$specificationSpecification.
Returns

Definition at line 172 of file AssertionChecker.php.

173  {
174  $old = $this->_specification;
175  $this->_specification = $specification;
176 
177  return $old;
178  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Praspel\AssertionChecker\AssertionChecker::$_callable = null
protected

Definition at line 78 of file AssertionChecker.php.

Hoa\Praspel\AssertionChecker\AssertionChecker::$_data = null
protected

Definition at line 64 of file AssertionChecker.php.

Hoa\Praspel\AssertionChecker\AssertionChecker::$_generateData = false
protected

Definition at line 71 of file AssertionChecker.php.

Hoa\Praspel\AssertionChecker\AssertionChecker::$_specification = null
protected

Definition at line 57 of file AssertionChecker.php.


The documentation for this class was generated from the following file: