Beispiel #1
0
 /**
  * Constraint for evaluation of table alias
  *
  * @param string $tableAlias
  * @param string $expectedTableName
  * @param string $type
  */
 public function __construct($tableAlias, $expectedTableName, $type = self::TYPE_TABLE_ALIAS)
 {
     if (!strpos($tableAlias, '/')) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'table alias', $tableAlias);
     }
     list($this->_tableAliasPrefix, $this->_tableAliasName) = explode('/', $tableAlias, 2);
     $this->_expectedValueValidation += array(self::TYPE_TABLE_ALIAS => array(true, 'is_string', 'string'));
     $this->_typesWithDiff[] = self::TYPE_TABLE_ALIAS;
     parent::__construct(self::XML_PATH_MODELS, $type, $expectedTableName);
 }
Beispiel #2
0
 /**
  * Contraint for evaluation of module config node
  *
  * @param string $nodePath
  * @param string $type
  * @param mixed $expectedValue
  */
 public function __construct($moduleName, $type, $expectedValue)
 {
     $this->_expectedValueValidation += array(self::TYPE_CODE_POOL => array(true, 'is_string', 'string'), self::TYPE_DEPENDS => array(true, 'is_string', 'string'), self::TYPE_EQUALS_VERSION => array(true, 'is_string', 'string'), self::TYPE_LESS_THAN_VERSION => array(true, 'is_string', 'string'), self::TYPE_GREATER_THAN_VERSION => array(true, 'is_string', 'string'));
     $this->_typesWithDiff[] = self::TYPE_CODE_POOL;
     $this->_typesWithDiff[] = self::TYPE_EQUALS_VERSION;
     $this->_typesWithDiff[] = self::TYPE_LESS_THAN_VERSION;
     $this->_typesWithDiff[] = self::TYPE_GREATER_THAN_VERSION;
     parent::__construct(sprintf(self::XML_PATH_MODULE_NODE, $moduleName), $type, $expectedValue);
     $this->_moduleName = $moduleName;
 }
Beispiel #3
0
 /**
  * Configuration constraint for cheking the existance of
  * layout file in configuration and a particular theme as well
  *
  * @param string $area design area (frontend|adminhtml)
  * @param string $expectedFile layout file name that should be checked
  * @param string $type type of assertion
  * @param string|null $layoutUpdate additional check for layout update name for assertion of configuration
  * @param string|null $theme additional check for layout file existance in a particular theme
  * @param string|null $designPackage additional check for layout file existance in a particular theme
  */
 public function __construct($area, $expectedFile, $type, $layoutUpdate = null, $theme = null, $designPackage = null)
 {
     $this->_area = $area;
     $this->_layoutUpdate = $layoutUpdate;
     $this->_designPackage = $designPackage;
     $this->_theme = $theme;
     $this->_expectedValueValidation += array(self::TYPE_LAYOUT_FILE => array(true, 'is_string', 'string'), self::TYPE_LAYOUT_DEFINITION => array(true, 'is_string', 'string'));
     $this->_typesWithDiff[] = self::TYPE_LAYOUT_FILE;
     $nodePath = sprintf(self::XML_PATH_LAYOUT, $area);
     parent::__construct($nodePath, $type, $expectedFile);
 }
Beispiel #4
0
 /**
  * Contraint for evaluation of config node
  *
  * @param string $moduleName
  * @param string $type
  * @param mixed $expectedValue
  */
 public function __construct($nodePath, $type, $expectedValue = null)
 {
     $this->_expectedValueValidation += array(self::TYPE_EQUALS_STRING => array(true, 'is_string', 'string'), self::TYPE_EQUALS_NUMBER => array(true, 'is_numeric', 'numeric'), self::TYPE_LESS_THAN => array(true, 'is_numeric', 'numeric'), self::TYPE_GREATER_THAN => array(true, 'is_numeric', 'numeric'), self::TYPE_CONTAIN_VALUE => array(true, 'is_scalar', 'scalar'), self::TYPE_HAS_CHILD => array(true, 'is_string', 'string'));
     $this->_typesWithDiff[] = self::TYPE_EQUALS_STRING;
     $this->_typesWithDiff[] = self::TYPE_EQUALS_BOOLEAN;
     $this->_typesWithDiff[] = self::TYPE_EQUALS_XML;
     $this->_typesWithDiff[] = self::TYPE_EQUALS_NUMBER;
     $this->_typesWithDiff[] = self::TYPE_LESS_THAN;
     $this->_typesWithDiff[] = self::TYPE_GREATER_THAN;
     parent::__construct($nodePath, $type, $expectedValue);
 }
Beispiel #5
0
 /**
  * Contraint for evaluation of module config node
  *
  * @param string $nodePath
  * @param string $type
  * @param string $moduleDirectory
  * @param mixed $expectedValue
  */
 public function __construct($moduleName, $type, $moduleDirectory, $resourceName = null, $expectedVersions = null)
 {
     $this->_typesWithDiff[] = self::TYPE_SCRIPT_SCHEME;
     $this->_typesWithDiff[] = self::TYPE_SCRIPT_DATA;
     parent::__construct(self::XML_PATH_RESOURCES_NODE, $type, $expectedVersions);
     $this->_moduleName = $moduleName;
     $this->_moduleDirectory = $moduleDirectory;
     $this->_resourceName = $resourceName;
     if (!is_dir($moduleDirectory)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'real directory', $moduleDirectory);
     }
 }
Beispiel #6
0
 /**
  * Constraint for evaluation of module config node
  *
  * @param string $nodePath
  * @param string $type
  * @param string $moduleDirectory
  * @param mixed $expectedValue
  */
 public function __construct($moduleName, $type, $moduleDirectory = null, $expectedValue = null)
 {
     $this->_expectedValueValidation += array(self::TYPE_SETUP_DEFINED => array(false, 'is_string', 'string'), self::TYPE_SETUP_SCHEME_EXISTS => array(false, 'is_string', 'string'), self::TYPE_SETUP_DATA_EXISTS => array(false, 'is_string', 'string'));
     $this->_typesWithDiff[] = self::TYPE_SETUP_DEFINED;
     $this->_typesWithDiff[] = self::TYPE_SETUP_SCHEME_EXISTS;
     $this->_typesWithDiff[] = self::TYPE_SETUP_DATA_EXISTS;
     parent::__construct(self::XML_PATH_RESOURCES_NODE, $type, $expectedValue);
     $this->_moduleName = $moduleName;
     $this->_moduleDirectory = $moduleDirectory;
     if (($this->_type === self::TYPE_SETUP_SCHEME_EXISTS || $this->_type === self::TYPE_SETUP_DATA_EXISTS) && !is_dir($moduleDirectory)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'real directory', $moduleDirectory);
     }
 }
Beispiel #7
0
 /**
  * Constraint for evaluation of grouped class alias (block, model, helper)
  *
  * @param string $group
  * @param string $classAlias
  * @param string $expectedClassName
  * @param string $type
  */
 public function __construct($group, $classAlias, $expectedClassName, $type = self::TYPE_CLASS_ALIAS)
 {
     if (!isset($this->_textByGroup[$group])) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(1, implode('|', array_keys($this->_textByGroup)), $group);
     }
     $this->_group = $group;
     if ($group === self::GROUP_HELPER && strpos($classAlias, '/') === false) {
         $classAlias .= '/data';
     }
     if (!strpos($classAlias, '/')) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class/alias', $classAlias);
     }
     list($this->_classAliasPrefix, $this->_classAliasName) = explode('/', $classAlias, 2);
     $nodePath = sprintf(self::XML_PATH_CLASS_ALIAS, $group, $this->_classAliasPrefix);
     $this->_expectedValueValidation += array(self::TYPE_CLASS_ALIAS => array(true, 'is_string', 'string'));
     $this->_typesWithDiff[] = self::TYPE_CLASS_ALIAS;
     parent::__construct($nodePath, $type, $expectedClassName);
 }
 /**
  * Constraint for testing observer
  * event definitions in configuration
  *
  * @param string $area
  * @param string $eventName
  * @param string $observerClassAlias
  * @param string $observerMethod
  * @param string|null $observerName
  */
 public function __construct($area, $eventName, $observerClassAlias, $observerMethod, $type = self::TYPE_DEFINDED, $observerName = null)
 {
     if (empty($area) || !is_string($area)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $area);
     }
     if (empty($eventName) || !is_string($eventName)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string', $eventName);
     }
     if (empty($observerClassAlias) || !is_string($observerClassAlias)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'string', $observerClassAlias);
     }
     if (empty($observerMethod) || !is_string($observerMethod)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'string', $observerMethod);
     }
     if ($observerName !== null && !is_string($observerName)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(6, 'string', $observerName);
     }
     $this->_area = $area;
     $this->_eventName = $eventName;
     $this->_observerClassAlias = $observerClassAlias;
     $this->_observerMethod = $observerMethod;
     $this->_observerName = $observerName;
     $expectedValue = $this->_observerClassAlias . '::' . $this->_observerMethod;
     $nodePath = sprintf(self::XML_PATH_EVENTS, $this->_area, $this->_eventName);
     parent::__construct($nodePath, $type, $expectedValue);
 }