/**
  * @param array $options
  *
  * @return ESGatewayUserRepo
  */
 public static function buildUserRepo(array $options)
 {
     self::validateOptions($options);
     $factory = new Factory();
     $client = $factory->makeClient($options['host'], $options['port']);
     $type = $factory->makeType($options['index'], $options['type']);
     $persist = new GatewayUserPersist($client, $type);
     $repo = new ESGatewayUserRepo($persist, $factory);
     return $repo;
 }
 protected function setUp()
 {
     $this->factory = new Factory();
     $index = 'farm';
     $typeName = 'user:tw';
     /* @var Client $esClient */
     $this->esClient = $esClient = Mockery::mock(Client::class);
     $this->type = $this->factory->makeType($index, $typeName);
     $this->userPersist = new GatewayUserPersist($esClient, $this->type);
     $this->userRepo = new ESGatewayUserRepo($this->userPersist, $this->factory);
     static::assertInstanceOf(ESGatewayUserRepo::class, $this->userRepo);
 }
 /**
  *
  */
 public function testMakeUser()
 {
     require_once __DIR__ . '/UserProvider.php';
     $jsonArr = \UserProvider::getJsonData();
     foreach ($jsonArr as $json) {
         $dbEntity = json_decode($json, true);
         static::assertArrayHasKey('snsid', $dbEntity);
         $userObj = $this->factory->makeUser($dbEntity);
         static::assertInstanceOf(User::class, $userObj);
         $userArr = $this->factory->toArray($userObj);
         static::assertArrayHasKey('snsid', $userArr);
         static::assertArrayHasKey('status', $userArr, print_r($userArr, true));
     }
 }
 /**
  * @return array
  */
 public static function listUser()
 {
     $jsonArr = self::getJsonData();
     $factory = new Factory();
     $users = [];
     $countries = ['TW', 'CN', 'TU'];
     foreach ($jsonArr as $json) {
         $dbEntity = json_decode($json, true);
         $dbEntity['logintime'] = time();
         $dbEntity['last_pay_time'] = time();
         $dbEntity['last_pay_amount'] = rand(10, 100);
         $dbEntity['history_pay_amount'] = rand(100, 1000);
         $dbEntity['country'] = $countries[array_rand($countries)];
         $users[] = $factory->makeUser($dbEntity);
     }
     return $users;
 }
 protected function setUp()
 {
     $this->factory = new Factory();
     /** @var Client $client */
     $this->client = $client = Mockery::mock(Client::class);
     $index = 'test';
     $typeName = 'user:tw';
     $this->type = $this->factory->makeType($index, $typeName);
     $this->persist = new GatewayUserPersist($client, $this->type);
 }
Example #6
0
 /**
  * @param array $users
  *
  * @return \ESGateway\User[]
  */
 private function sanitizeData(array $users)
 {
     return array_map(function (array $eachUser) {
         return $this->userDataFactory->makeUser($eachUser);
     }, $users);
 }