/**
  *  Convert data array into entity
  *
  *  @return VoucherType
  *  @param array $data
  *  @access public
  */
 public function build($data)
 {
     $oEntity = new VoucherType();
     $sAlias = $this->getTableQueryAlias();
     $iVoucherTypeId = $this->getField($data, 'voucher_type_id', $sAlias);
     $sName = $this->getField($data, 'voucher_name', $sAlias);
     $sDescription = $this->getField($data, 'voucher_description', $sAlias);
     $oEnableFrom = $this->getField($data, 'voucher_enabled_from', $sAlias);
     $oEnableTo = $this->getField($data, 'voucher_enabled_to', $sAlias);
     $sSlugName = $this->getField($data, 'voucher_name_slug', $sAlias);
     $iVoucherGroupId = $this->getField($data, 'voucher_group_id', $sAlias);
     $iVoucherGenRuleId = $this->getField($data, 'voucher_gen_rule_id', $sAlias);
     $oEntity->setVoucherTypeId($iVoucherTypeId);
     $oEntity->setEnabledFrom($oEnableFrom);
     $oEntity->setEnabledTo($oEnableTo);
     $oEntity->setName($sName);
     $oEntity->setSlug($sSlugName);
     $oEntity->setDescription($sDescription);
     $oEntity->setVoucherGroupId($iVoucherGroupId);
     $oEntity->setVoucherGenRuleId($iVoucherGenRuleId);
     return $oEntity;
 }
 public function testVoucherTypeValidationFailed()
 {
     $oVoucher = new VoucherType();
     $iVoucherTypeId = null;
     $sName = str_repeat('a', 101);
     $sSlugName = str_repeat('a', 101);
     $sDescription = 'A sucessful test voucher';
     $oEnableFrom = new DateTime();
     $oEnableTo = new DateTime('NOW - 5 days');
     $iVoucherGroupId = 0;
     $iVoucherGenRuleId = 0;
     $oVoucher->setVoucherTypeId($iVoucherTypeId);
     $oVoucher->setSlug($sSlugName);
     $oVoucher->setName($sName);
     $oVoucher->setDescription($sDescription);
     $oVoucher->setEnabledFrom($oEnableFrom);
     $oVoucher->setEnabledTo($oEnableTo);
     $oVoucher->setVoucherGroupId($iVoucherGroupId);
     $oVoucher->setVoucherGenruleId($iVoucherGenRuleId);
     $oResults = $oVoucher->validate();
     $this->assertInternalType('array', $oResults);
     $this->assertEquals(count($oResults['voucherGroupId']), 1);
     $this->assertEquals(count($oResults['voucherGenRuleId']), 1);
     $this->assertEquals(count($oResults['voucherTypeId']), 1);
     $this->assertEquals(count($oResults['voucherName']), 1);
     $this->assertEquals(count($oResults['voucherNameSlug']), 1);
     $this->assertEquals(count($oResults['voucherEnabledFrom']), 1);
 }