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); }
/** * Convert and entity into a data array that match database columns in table * * @return array * @access public * @param VoucherType $entity A voucher type entity */ public function demolish($entity) { $aData = array('voucher_type_id' => $entity->getVoucherTypeId(), 'voucher_enabled_from' => $entity->getEnabledFrom(), 'voucher_enabled_to' => $entity->getEnabledTo(), 'voucher_name' => $entity->getName(), 'voucher_name_slug' => $entity->getSlug(), 'voucher_description' => $entity->getDescription(), 'voucher_group_id' => $entity->getVoucherGroupId(), 'voucher_gen_rule_id' => $entity->getVoucherGenRuleId()); return $aData; }