build sepcification data before real test

@param array $data
977504
public function prepare(array $data = null)
    {
        $response = [];
        $code     = 200;
        try {
            if (!isset($data['module']) or empty($data['module'])) {
                throw new Exception\InvalidArgumentException(
                'Unable to start tests. No module has been selected.');
            }

            $selected = array_keys($data['module']);

            $tests  = app('antares.memory')->make('tests')->all();
            $active = app('antares.memory')->get("extensions.active");
            foreach ($tests as $name => $test) {

                if (in_array($test['id'], $selected)) {
                    $fullName   = isset($active[$test['component']]) ? $active[$test['component']]['full_name'] : 'Foundation';
                    $response[] = [
                        'cid'     => $test['id'],
                        'message' => "Currently testing {$name}  in {$fullName}."
                    ];
                }
            }
        } catch (\Exception $ex) {
            Log::warning($ex);
            $code       = 400;
            $response[] = [
                'error' => $ex->getMessage()
            ];
        }

        return Response::json($response, $code);
    }
874965
public function mergeData(array $data)
    {
        $args = func_get_args();
        foreach ($args as $key => $v) {
            if (is_array($v)) {
                $this->data = array_merge($this->data, $v);
            }
        }
    }
324610
public function build(array $data = [])
    {
        if(!$this->oAuth2Credential)
            $this->oAuth();

        $data = $this->mergeData($data);

        $adwordsSession = new AdWordsSessionBuilder();

        return $adwordsSession->withDeveloperToken($data['developerToken'])
                ->withClientCustomerId($data['clientCustomerId'])
                ->withOAuth2Credential($this->oAuth2Credential)
                ->build();
    }
521308
public function runBeforeSave(array &$data)
    {
        $beforeSave = $this->getOption('before_save');

        if (is_callable($beforeSave)) {
            $bs = $beforeSave($data);

            //if a string is returned, assume it's an error and kick it back
            if (is_string($bs)) {
                return $bs;
            }
        }

        return true;
    }
333671
protected static function checkNew(array $data)
    {
        $errors = [];
        if ($missing = array_diff(static::getRequired(), array_keys($data))) {
            $errors[] = 'Missing: ' . implode(', ', $missing);
        }
        foreach ($data as $key => $value) {
            $errors += static::checkProperty($key, $value);
        }
        return $errors;
    }
1293393
public function setData(array $data)
    {
        $this->isMergingData = true;
        /**
         * @todo Kinda hacky, but works with the concept of form.
         *     Should work embeded in a form group or in a dashboard.
         */
        $data = array_merge($_GET, $data);

        parent::setData($data);

        /** Merge any available presets */
        $data = $this->mergePresets($data);

        parent::setData($data);

        $this->isMergingData = false;

        if ($this->lang()) {
            $this->translator()->setLocale($this->lang());
        }

        return $this;
    }
794333
protected function prepareData($data)
    {
        if(!is_array($data))
        {
            $data = [];
        }
        
        $data['access_token'] = $this->config->accessToken;
        
        return http_build_query($data);
    }
1010686
public function set(array $data)
    {
        $build = $this->build($data);

        if (empty($build['asset'])) {
            return false;
        }

        if (!empty($build['merge']) && is_array($build['asset'])) {
            if (isset($this->assets[$build['type']][$build['position']][$build['merge']])) {
                $existing = $this->assets[$build['type']][$build['position']][$build['merge']]['asset'];
                $this->assets[$build['type']][$build['position']][$build['merge']]['asset'] = array_merge($existing, $build['asset']);
            }
        }

        if (isset($this->assets[$build['type']][$build['position']][$build['key']])) {
            return false;
        }

        $this->assets[$build['type']][$build['position']][$build['key']] = $build;
        return $this->assets[$build['type']];
    }
317498
protected function prepareData(&$data)
    {
        // Remove MatchOn Filter:
        
        $name = $this->getMatchOnName();
        
        if (isset($data[$name])) {
            unset($data[$name]);
        }
    }
378536
private function setData(array $data)
    {
        $_documentClass = $this->_documentClass;
        $_edgeClass = $this->_edgeClass;

        if (isset($this->_options[self::ENTRY_FLAT]) && $this->_options[self::ENTRY_FLAT]) {
            $this->_result = $data;
        } else {
            $this->_result = [];

            if ($this->_options[self::ENTRY_TYPE] === Collection::TYPE_EDGE) {
                foreach ($data as $row) {
                    $this->_result[] = $_edgeClass::createFromArray($row, $this->_options);
                }
            } else {
                foreach ($data as $row) {
                    $this->_result[] = $_documentClass::createFromArray($row, $this->_options);
                }
            }
        }
    }
1161149
private function initializeType(array $data)
    {
        if (isset($data['type']) === false) {
            return;
        }

        if ($data['type'] === 'error') {
            $this->type = self::TYPE_ERROR;
        } elseif ($data['type'] === 'info') {
            if (isset($data['subType']) === true &&
                $data['subType'] === 'warning'
            ) {
                $this->type = self::TYPE_WARNING;
            } else {
                $this->type = self::TYPE_INFO;
            }
        }
    }
80872
protected function initialize($data)
    {
        //Force conversion to array
        if (is_object($data)) $data = (array) $data;
        $schema = $this->_jsonSchema;

        /*
        * Alias management
        */
        foreach ($schema['definition'] as $property => $definition) {
            $alias = $definition['alias'];
            if ($alias && array_key_exists($alias, $data)) {
                $method = 'set' . ucfirst($alias);
                if (method_exists($this, $method)) {
                    $data[$property] = $this->$method($data[$alias]);
                } else {
                    $data[$property] = $data[$alias];
                }
            }
        }

        /**
         * Initialize data
         * Also create empty composed Store
         */

        foreach ($schema['definition'] as $property => $definition) {
            if (!in_array($property, $this->_storePropertiesCache)) {
                continue;
            }

            if ($definition['internal']) {
                continue;
            }

            //Find the value if there is one.
            if (!is_array($data)) {
                if (is_string($data)) {
                    throw new StoreException(
                        "Error initializing the store. Expected array on init data but got string : '".$data."'"
                        . " for property $property"
                    );
                } elseif (is_bool($data)) {
                    $value = "true";
                    if(!$data) $value = "false";
                    throw new StoreException(
                        "Error initializing the store. Expected array on init data but got boolean with (".$data.") value"
                        . " for property $property"
                    );
                } elseif (is_numeric($data)) {
                    throw new StoreException(
                        "Error initializing the store. Expected array on init data but got a numeric value : ".$data
                        . " for property $property"
                    );
                } else {
                    throw new StoreException(
                        "Error initializing the store. Expected array on init data but got ".gettype($data)
                        . " for property $property"
                    );
                }
            }
            if (array_key_exists($property, $data))
                $value = $data[$property];
            else {
                //To get default values
                $value = $this->$property;
            }

            /**
             * if we receive a array, but it's defined as object, we convert it
             * If not, the cast to Store is not done
             */
            if ($definition['type'] == 'object' && is_array($value)) {
                $value = (object) $value;
                $data[$property] = $value;
            }

            /**
             * if we receive a array, but it's defined as object, we convert it
             * If not, the cast to Store is not done
             */
            if ($definition['type'] == 'array' && is_object($value)) {
                $value = (array) $value;
                $data[$property] = $value;
            }


            /**
             * unSerialize Value
             */
            if (isset($definition['storeClasses'])) $storeClasses = $definition['storeClasses'];
            else $storeClasses = array();

            $storeClass = $this->getStoreClass(null, $storeClasses);

            if ($value) {
                $value = $this->unSerialize($value, $storeClasses, $definition);
            } elseif ($storeClass && $definition['type'] == 'object') {

                /**
                 * We create a store with no values only if it's NotNone
                 */
                if (in_array('NotBlank', $definition['validationConstraints'])) {
                    $value = StoreHelper::createClass($storeClass, $data);
                }

            } elseif ($definition['type'] == 'array') {
                $value = array();
            }

            if (!is_null($value)) {
                $method = 'set' . ucfirst($property);
                $this->_setPropertyValue($property, $value);
            }
        }
    }
1236154
public function build(array $data = array())
    {
        $data += array(
            'page' => 1,
            'limit' => 0,
            'total' => 0,
            'mini' => false,
            'max_pages' => 10,
            'query' => array()
        );

        $this->setPage($data['page'])
            ->setPerPage($data['limit'])
            ->setTotal($data['total'])
            ->setMaxPages($data['max_pages'])
            ->setUrlPattern('?' . urldecode(http_build_query($data['query'])));

        return $this;
    }
773594
protected function loadData(array $data = [])
    {
        foreach ($data as $key => $value) {
            if (property_exists($this, $key)) {
                $this->$key = $value;
            }
        }
    }
1302948
private function prepareAttributes(array $data)
    {
        foreach ($data as $key => &$value) {
            if (is_array($value)) {
                $data[$key] = $this->prepareAttributes($value);
                continue;
            }

            if (is_float($value)) {
                $value = sprintf("%01.2f", $value);
            }
        }

        return $data;
    }
47011
public function unserialize($data)
    {
        $data = unserialize($data);

        $this->item = $data['item'];
        $this->separator = $data['separator'];
        $this->constraint = $data['constraint'];
    }
1076792
public function setup($data = array())
	{

		foreach (self::$_KEYS as $k)
		{
			if (array_key_exists($k, $data))
			{
				$this->_API[$k] = self::verifySetup($k, $data[$k]);
			}
		}
	}