123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace tests\unit\Util;
- use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
- class EntityDataObjectBuilder
- {
- /**
- * Array of data fields for the object. Has fields contained by default.
- *
- * @var array
- */
- private $data = [
- "name" => "Hopper",
- "gpa" => "3.5678",
- "phone" => "5555555",
- "isprimary" => "true"
- ];
- /**
- * Name of the data object.
- *
- * @var string
- */
- private $name = "testDataObject";
- /**
- * Name of the data object type (e.g. customer, category etc.)
- *
- * @var string
- */
- private $type = "testType";
- /**
- * A flat array containing linked entity name => linked entity type.
- *
- * @var array
- */
- private $linkedEntities = [];
- /**
- * An array contain references to data to be resolved by the api.
- *
- * @var array
- */
- private $vars = [];
- /**
- * A function which will build an Entity Data Object with the params specified by the object.
- *
- * @return EntityDataObject
- */
- public function build()
- {
- return new EntityDataObject(
- $this->name,
- $this->type,
- $this->data,
- $this->linkedEntities,
- null,
- $this->vars
- );
- }
- /**
- * Sets the name of the EntityDataObject.
- *
- * @param string $name
- * @return EntityDataObjectBuilder
- */
- public function withName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * Sets the type of the EntityDataObject.
- *
- * @param string $type
- * @return EntityDataObjectBuilder
- */
- public function withType($type)
- {
- $this->type = $type;
- return $this;
- }
- /**
- * Sets the data fields on the object to the data field array specified in the argument.
- *
- * @param array $fields
- * @return EntityDataObjectBuilder
- */
- public function withDataFields($fields)
- {
- $this->data = $fields;
- return $this;
- }
- /**
- * Sets the linked entities specified by the user as a param for Entity Data Object creation.
- *
- * @param array $linkedEntities
- * @return EntityDataObjectBuilder
- */
- public function withLinkedEntities($linkedEntities)
- {
- $this->linkedEntities = $linkedEntities;
- return $this;
- }
- }
|