Ejemplo n.º 1
0
 public function testTypeAdapter()
 {
     $f = new TestFixture();
     $a = PHPFIT_TypeAdapter::on($f, "sampleInt", $f, 'field');
     $a->set($a->parse("123456"));
     $this->assertTrue(is_int($a->parse("123456")));
     $this->assertEqual(123456, $f->sampleInt);
     $this->assertEqual("-234567", strval($a->parse("-234567")));
     $a = PHPFIT_TypeAdapter::on($f, "sampleFloat", $f, 'field');
     $a->set($a->parse("2.34"));
     $this->assertTrue(is_float($a->parse("2.34")));
     $this->assertTrue(abs(2.34 - $f->sampleFloat) < 1.0E-5);
     $a = PHPFIT_TypeAdapter::on($f, "pi", $f, 'method');
     $this->assertTrue(is_float($a->invoke()));
     $this->assertTrue(abs(3.14159 - $a->invoke()) < 1.0E-5);
     $a = PHPFIT_TypeAdapter::on($f, "name", $f, 'field');
     $a->set($a->parse("xyzzy"));
     $this->assertTrue(is_string($a->parse("xyzzy")));
     $this->assertEqual("xyzzy", $f->name);
     $a = PHPFIT_TypeAdapter::on($f, "sampleBoolean", $f, 'field');
     $a->set($a->parse("true"));
     $this->assertTrue(is_bool($a->parse("true")));
     $this->assertEqual(true, $f->name);
     // TODO: Arrays and Dates
 }
Ejemplo n.º 2
0
 /**
  * Implements check fixture
  *
  * Check aMethod aValue - Invoke aMethod with no arguments.
  * Compare the returned value with aValue. This is similar to reading
  * values from a GUI screen.
  *
  */
 public function check()
 {
     $aMethod = $this->camel($this->cells->more->text());
     $aValue = $this->cells->more->more;
     $adapter = PHPFIT_TypeAdapter::on(self::$actor, $aMethod, self::$actor, 'method');
     $this->checkCell($aValue, $adapter);
 }
Ejemplo n.º 3
0
 function execute()
 {
     $adapter = PHPFIT_TypeAdapter::on($this, 'validateAndSave', $this->getSystemUnderTest(), 'method');
     return $adapter->validateAndSave($this->columnBindings);
 }
Ejemplo n.º 4
0
 /** Call a method with parameters
  * @param DoCells $doCells holding action name and params
  * @param PHPFIT_TypeAdapter $adapter 
  * 		If no adapter is supplied, this method will create one on the  systemUnderTest. 
  * 		This allows tests call a non-existent method. Risk is that a fatal error may occur. 
  * @return mixed the result of the method call
  */
 function call($doCells, $adapter = null)
 {
     if (!$adapter) {
         $adapter = \PHPFIT_TypeAdapter::on($this, $doCells->getName(), $this->getSystemUnderTest(), 'method');
     }
     $doCells->setAdapter($adapter);
     //result-adapter
     $arguments = $this->parseArgumentsForMethod($adapter->target, $doCells->getName(), $doCells->getParams(), $adapter);
     return call_user_func_array(array($adapter->target, $doCells->getName()), $arguments);
 }
Ejemplo n.º 5
0
 /**
  * @param String $name
  * @return PHPFIT_TypeAdapter
  */
 protected function bindField($name)
 {
     return PHPFIT_TypeAdapter::on($this, $name, $this->getTargetClass(), 'field');
 }