/**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->object = new WirecardCEE_QPay_FrontendClient();
     $this->aUserConfig = WirecardCEE_QPay_Module::getConfig();
     $this->aClientConfig = WirecardCEE_QPay_Module::getClientConfig();
     $this->aExpectedRequestData = array(WirecardCEE_QPay_FrontendClient::CUSTOMER_ID => $this->aUserConfig['WirecardCEEQPayConfig']['CUSTOMER_ID'], WirecardCEE_QPay_FrontendClient::SHOP_ID => $this->aUserConfig['WirecardCEEQPayConfig']['SHOP_ID'], WirecardCEE_QPay_FrontendClient::LANGUAGE => $this->aUserConfig['WirecardCEEQPayConfig']['LANGUAGE']);
 }
 public function testUserConfig()
 {
     $aConfig = WirecardCEE_QPay_Module::getConfig();
     $this->assertInternalType('array', $aConfig);
     $this->assertArrayHasKey('WirecardCEEQPayConfig', $aConfig);
     $this->assertArrayHasKey('CUSTOMER_ID', $aConfig['WirecardCEEQPayConfig']);
     $this->assertArrayHasKey('SHOP_ID', $aConfig['WirecardCEEQPayConfig']);
     $this->assertArrayHasKey('LANGUAGE', $aConfig['WirecardCEEQPayConfig']);
     $this->assertArrayHasKey('SECRET', $aConfig['WirecardCEEQPayConfig']);
 }
 public static function fingerprintProvider()
 {
     return array(array('values' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'secret' => WirecardCEE_QPay_Module::getConfig()['WirecardCEEQPayConfig']['SECRET']), 'fingerprintOrder' => array('key1', 'key2', 'key3', 'key4', 'secret'), 'hash' => '6c8bc309cbdf78770fd4820c12a6573c1fb6371ba86a4a34e5226dc529d70cb61cbec1af21faaf0567aeabad868acf9bf08030caec008ff2c8856bae676801e8'), array('values' => array('key1' => 'äöü', 'key2' => '#+ü', 'key3' => '///', 'key4' => 'bla', 'secret' => WirecardCEE_QPay_Module::getConfig()['WirecardCEEQPayConfig']['SECRET']), 'fingerprintOrder' => array('key1', 'key2', 'key3', 'key4', 'secret'), 'hash' => '3af32ea6d1bc69284625b6d245d84aadc6b8df0df131090e7265c5919bb76eadd0d72a63646da0d8019036c409f91b6ab9a7e6cae661ad4528d15db50b4c4678'));
 }
 /**
  * Constructor
  *
  * @param mixed $aConfig
  *
  * @throws WirecardCEE_QPay_Exception_InvalidParamLengthException
  * @throws WirecardCEE_QPay_Exception_InvalidArgumentException
  * @formatter:off
  */
 public function __construct($aConfig = null)
 {
     $this->_fingerprintOrder = new WirecardCEE_Stdlib_FingerprintOrder();
     //if no config was sent fallback to default config file
     if (is_null($aConfig)) {
         $aConfig = WirecardCEE_QPay_Module::getConfig();
     }
     if (isset($aConfig['WirecardCEEQPayConfig'])) {
         //we only need the WirecardCEEQPayConfig here
         $aConfig = $aConfig['WirecardCEEQPayConfig'];
     }
     //let's store configuration details in internal objects
     $this->oUserConfig = new WirecardCEE_Stdlib_Config($aConfig);
     $this->oClientConfig = new WirecardCEE_Stdlib_Config(WirecardCEE_QPay_Module::getClientConfig());
     //now let's check if the CUSTOMER_ID, SHOP_ID, LANGUAGE and SECRET exist in $this->oUserConfig object that we created from config array
     $sCustomerId = isset($this->oUserConfig->CUSTOMER_ID) ? trim($this->oUserConfig->CUSTOMER_ID) : null;
     $sShopId = isset($this->oUserConfig->SHOP_ID) ? trim($this->oUserConfig->SHOP_ID) : null;
     $sLanguage = isset($this->oUserConfig->LANGUAGE) ? trim($this->oUserConfig->LANGUAGE) : null;
     $sSecret = isset($this->oUserConfig->SECRET) ? trim($this->oUserConfig->SECRET) : null;
     //If not throw the InvalidArgumentException exception!
     if (empty($sCustomerId) || is_null($sCustomerId)) {
         throw new WirecardCEE_QPay_Exception_InvalidArgumentException(sprintf('CUSTOMER_ID passed to %s is invalid.', __METHOD__));
     }
     if (empty($sLanguage) || is_null($sLanguage)) {
         throw new WirecardCEE_QPay_Exception_InvalidArgumentException(sprintf('LANGUAGE passed to %s is invalid.', __METHOD__));
     }
     if (empty($sSecret) || is_null($sSecret)) {
         throw new WirecardCEE_QPay_Exception_InvalidArgumentException(sprintf('SECRET passed to %s is invalid.', __METHOD__));
     }
     // we're using hmac sha512 for hash-ing
     WirecardCEE_Stdlib_Fingerprint::setHashAlgorithm(WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_HMAC_SHA512);
     //everything ok! let's set the fields
     $this->_setField(self::CUSTOMER_ID, $sCustomerId);
     $this->_setField(self::SHOP_ID, $sShopId);
     $this->_setField(self::LANGUAGE, $sLanguage);
     $this->_setSecret($sSecret);
 }