Пример #1
0
    /**
     * Builds the initial setup of the test class
     * @return void
     * @throws \Exception
     */
    private function buildTestSetup()
    {
        $this->getTestClass()->addUse('Bullhorn\\FastRest\\UnitTestHelper\\MockDbAdapter');
        $variable = new Object\Variable();
        $variable->setName('model');
        $variable->setType($this->getAbstractClass()->getName());
        $this->getTestClass()->addVariable($variable);
        $method = new Object\Method();
        $method->setName('getModel');
        $method->setReturnType($this->getAbstractClass()->getName());
        $method->setContent('return $this->model;');
        $this->getTestClass()->addMethod($method);
        $method = new Object\Method();
        $method->setName('getDbMock');
        $method->setReturnType('MockDbAdapter');
        $method->setContent('return $this->getDi()->get($this->getConnectionService());');
        $this->getTestClass()->addMethod($method);
        $method = new Object\Method();
        $method->setName('setUp');
        $content = '$this->setModelSubNamespace(\'' . $this->getConfiguration()->getModelSubNamespace() . '\');
		$this->setConnectionService(\'' . $this->getConfiguration()->getConnectionService() . '\');
		$this->setPhalconHelperNamespace(\'' . $this->getConfiguration()->getRootNamespace() . '\\PhalconHelper\');
		parent::setUp();
		$this->model = $this->getMockForAbstractClass(\'' . $this->getAbstractClass()->getNamespace() . '\\' . $this->getAbstractClass()->getName() . '\', [$this->getDi()]);';
        $method->setContent($content);
        $this->getTestClass()->addMethod($method);
    }
Пример #2
0
 /**
  * Adds a new method
  *
  * @param Variable $variable
  *
  * @return void
  * @throws \Exception
  */
 public function addVariable(Variable $variable)
 {
     $variables = $this->getVariables();
     $key = $variable->getName();
     if (array_key_exists($key, $variables)) {
         throw new \Exception('A Variable with the name of: ' . $variable->getName() . ' already exists');
     }
     $variables[$key] = $variable;
     ksort($variables);
     $this->setVariables($variables);
 }