aboutsummaryrefslogtreecommitdiffstats
path: root/Praspel.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-13 10:10:40 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-13 10:10:40 +0200
commit27d4a368a6ba05695f2c5b1dadf1ed27534aa2b9 (patch)
tree2dda937fa1c4725ce77b48085c497309a77b667d /Praspel.php
parent01d2721d5d533ef633af4576fade0dca6e6fe0dd (diff)
downloadPraspel-27d4a368a6ba05695f2c5b1dadf1ed27534aa2b9.zip
Praspel-27d4a368a6ba05695f2c5b1dadf1ed27534aa2b9.tar.gz
Praspel-27d4a368a6ba05695f2c5b1dadf1ed27534aa2b9.tar.bz2
Add auto data generation.
Diffstat (limited to 'Praspel.php')
-rw-r--r--Praspel.php47
1 files changed, 43 insertions, 4 deletions
diff --git a/Praspel.php b/Praspel.php
index fa6a842..c3c3fcd 100644
--- a/Praspel.php
+++ b/Praspel.php
@@ -124,6 +124,13 @@ class Praspel {
protected $_data = null;
/**
+ * Whether we are able to automatically generate data.
+ *
+ * @var \Hoa\Praspel bool
+ */
+ protected $_generateData = false;
+
+ /**
* Callable to validate and verify.
*
* @var \Hoa\Core\Consistency\Xcallable object
@@ -145,13 +152,16 @@ class Praspel {
* @access public
* @param \Hoa\Praspel\Model\Specification $specification Specification.
* @param \Hoa\Core\Consistency\Xcallable $callable Callable.
+ * @param bool $genrateData Generate data.
* @return void
*/
public function __construct ( Model\Specification $specification,
- \Hoa\Core\Consistency\Xcallable $callable ) {
+ \Hoa\Core\Consistency\Xcallable $callable,
+ $generateData = false ) {
$this->setSpecification($specification);
$this->setCallable($callable);
+ $this->automaticallyGenerateData($generateData);
return;
}
@@ -180,9 +190,12 @@ class Praspel {
// Prepare data.
if(null === $data = $this->getData())
- throw new Exception\Generic(
- 'No data were given. The System Under Test %s needs data to ' .
- 'be executed.', 1, $callable);
+ if(true === $this->canGenerateData())
+ $data = $this->generateData();
+ else
+ throw new Exception\Generic(
+ 'No data were given. The System Under Test %s needs data ' .
+ 'to be executed.', 1, $callable);
$arguments = array();
@@ -525,6 +538,32 @@ class Praspel {
}
/**
+ * Enable or disable the automatic data generation.
+ *
+ * @access public
+ * @param bool $generateData Generate data or not.
+ * @return bool
+ */
+ public function automaticallyGenerateData ( $generateData ) {
+
+ $old = $this->_generateData;
+ $this->_generateData = $generateData;
+
+ return $old;
+ }
+
+ /**
+ * Whether we are able to automatically generate data.
+ *
+ * @access public
+ * @return bool
+ */
+ public function canGenerateData ( ) {
+
+ return $this->_generateData;
+ }
+
+ /**
* Set data.
*
* @access public