Пример #1
0
 /**
  * Returns the form value of the given unit
  *
  * @param Unit  $unit          unit that holds the form value
  * @param mixed $key           key of the requested form value
  * @param mixed $fallbackValue result if formValue array misses key
  *
  * @return mixed
  */
 public function getFormValue(Unit $unit, $key, $fallbackValue = null)
 {
     $formValues = $unit->getFormValues();
     if (!(is_array($formValues) && array_key_exists($key, $formValues))) {
         return $fallbackValue;
     }
     return $formValues[$key];
 }
Пример #2
0
 /**
  * @test
  * @group rendering
  * @group small
  * @group dev
  */
 public function test_createNewInstance()
 {
     // ARRANGE
     $expectedId = 'this is the unit id';
     $expectedModuleId = 'this is the unit module id';
     $expectedName = 'this is the unit name';
     $expectedFormValues = array('this is one unit form value');
     $expectedGhostContainer = true;
     $expectedTemplateUnitId = 'this is the unit template id';
     $expectedHtmlClass = 'this is the html class';
     // ACT
     $actualUnit = new Unit($expectedId, $expectedModuleId, $expectedName, $expectedFormValues, $expectedGhostContainer, $expectedTemplateUnitId, $expectedHtmlClass);
     // ASSERT
     $this->assertEquals($expectedId, $actualUnit->getId());
     $this->assertEquals($expectedModuleId, $actualUnit->getModuleId());
     $this->assertEquals($expectedName, $actualUnit->getName());
     $this->assertEquals($expectedFormValues, $actualUnit->getFormValues());
     $this->assertEquals($expectedGhostContainer, $actualUnit->isGhostContainer());
     $this->assertEquals($expectedTemplateUnitId, $actualUnit->getTemplateUnitId());
     $this->assertEquals($expectedHtmlClass, $actualUnit->getHtmlClass());
 }