You are here

protected function ConditionTest::setUp in Apigee Edge 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/ConditionTest.php, line 321

Class

ConditionTest
Entity query condition tests.

Namespace

Drupal\Tests\apigee_edge\Unit

Code

protected function setUp() {
  parent::setUp();
  for ($i = 0; $i < 1024; $i++) {
    $this->entityData[] = [
      $this
        ->getRandomGenerator()
        ->name(),
      (int) mt_rand(1, 1024 * 1024 * 1024),
      (bool) mt_rand(0, 1),
    ];
  }
  $this->entities = array_map(function ($data) {
    return new class($data[0], $data[1], $data[2]) implements EntityInterface {

      /**
       * @var string
       */
      protected $id;

      /**
       * @var int
       */
      protected $fooBar;

      /**
       * @var bool
       */
      protected $fooBaz;

      /**
       * Constructs a new dummy entity.
       *
       * @param string $id
       *   ID of the entity.
       * @param int $foo_bar
       *   Dummy property.
       * @param bool $foo_baz
       *   Dummy property.
       */
      public function __construct(string $id, int $foo_bar, bool $foo_baz) {
        $this->id = $id;
        $this->fooBar = $foo_bar;
        $this->fooBaz = $foo_baz;
      }

      /**
       * {@inheritdoc}
       */
      public static function idProperty() : string {
        return 'id';
      }

      /**
       * {@inheritdoc}
       */
      public function id() : ?string {
        return $this->id;
      }

      /**
       * @return int
       *   Returns an int.
       */
      public function getFooBar() : int {
        return $this->fooBar;
      }

      /**
       * @param int $foo_bar
       *   Value to set.
       */
      public function setFooBar(int $foo_bar) : void {
        $this->fooBar = $foo_bar;
      }

      /**
       * @return bool
       *   Returns true of false.
       */
      public function isFooBaz() : bool {
        return $this->fooBaz;
      }

      /**
       * @param bool $foo_baz
       *   Value to set.
       */
      public function setFooBaz(bool $foo_baz) : void {
        $this->fooBaz = $foo_baz;
      }

    };
  }, $this->entityData);
}