/**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->connection = Connection::get();
     $this->userBook = new UserBook($this->connection);
     $this->providerInfoBook = new ProviderInfoBook($this->connection);
     $this->providerUserBook = new ProviderUserBook($this->connection);
     foreach ($this->providerInfoBook->get() as $providerInfo) {
         $this->providerInfoBook->delete($providerInfo);
     }
     foreach ($this->userBook->get() as $user) {
         $this->userBook->delete($user);
     }
     for ($k = 0; $k < 10; $k++) {
         $user = new User();
         $user->setEnabled(RandomBook::getRandomBoolean())->setEnabledDate(RandomBook::getRandomDate())->setAccessFailedCount(rand(1, 5))->setEmail(RandomBook::getRandomEmail())->setPassword(RandomBook::getRandomString())->setPhoneNumber(RandomBook::getRandomPhoneNumber())->setTwoFactorEnabled(RandomBook::getRandomBoolean())->setUserName(RandomBook::getRandomString());
         $user->setId($this->userBook->save($user));
         $this->userList[] = $user;
         for ($k = 0; $k < 10; $k++) {
             $providerInfo = new ProviderInfo();
             $providerInfo->setName(RandomBook::getRandomString())->setAppKey(RandomBook::getRandomString())->setSecretKey(RandomBook::getRandomString());
             $providerInfo->setId((int) $this->providerInfoBook->save($providerInfo));
             $this->providerInfoList[] = $providerInfo;
             $providerUser = new ProviderUser();
             $providerUser->setUserId($user->getId())->setProviderId($providerInfo->getId())->setProviderName($providerInfo->getName())->setProviderUserId(RandomBook::getRandomString());
             $this->providerUserList[] = $providerUser;
         }
     }
 }
 public function testSaveAndGet()
 {
     for ($i = 0; $i < count($this->providerInfoList); $i++) {
         /* @var $providerInfo ProviderInfo */
         $providerInfo = $this->providerInfoList[$i];
         $providerInfo->setId($this->providerInfoBook->save($this->providerInfoList[$i]));
         $this->providerInfoList[$i] = $providerInfo;
     }
     $providerInfosInDB = $this->providerInfoBook->get();
     $this->assertEquals(count($this->providerInfoList), count($providerInfosInDB));
     for ($i = 0; $i < count($this->providerInfoList); $i++) {
         $currentProviderInfo = $this->providerInfoList[$i];
         $providerInfosInDb = $this->providerInfoBook->get($currentProviderInfo->getId());
         $providerInfoInDB = $providerInfosInDb[0];
         $this->assertEquals($currentProviderInfo, $providerInfoInDB);
     }
 }
Exemplo n.º 3
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->connection = Connection::get();
     $this->userBook = new UserBook($this->connection);
     $this->providerInfoBook = new ProviderInfoBook($this->connection);
     $this->roleBook = new RoleBook($this->connection);
     foreach ($this->providerInfoBook->get() as $providerInfo) {
         $this->providerInfoBook->delete($providerInfo);
     }
     foreach ($this->roleBook->get() as $role) {
         $this->roleBook->delete($role);
     }
     for ($k = 0; $k < 10; $k++) {
         $user = new User();
         $user->setEnabled(RandomBook::getRandomBoolean())->setEnabledDate(RandomBook::getRandomDate())->setAccessFailedCount(rand(1, 5))->setEmail(RandomBook::getRandomEmail())->setPassword(RandomBook::getRandomString())->setPhoneNumber(RandomBook::getRandomPhoneNumber())->setTwoFactorEnabled(RandomBook::getRandomBoolean())->setUserName(RandomBook::getRandomString());
         $this->userList[] = $user;
     }
 }