コード例 #1
0
ファイル: Init.php プロジェクト: stanislav-web/phalcon-ulogin
 /**
  * Allows you to add authentication providers in the list of available.
  *
  * @param mixed $providers as ('provider' => true, 'provider' => false) or string separated by comma
  * @example <code>
  *                         $this->setProviders([
  *                         'vkontakte'     =>  true,
  *                         'odnoklassniki' =>  true,
  *                         'mailru'        =>  true,
  *                         'facebook'      =>  true,
  *                         'twitter'       =>  false,  // in drop down
  *                         'google'        =>  false,  // in drop down
  *                         'yandex'        =>  false,  // in drop down
  *                         'livejournal'   =>  false,  // in drop down
  *                         'openid'        =>  false   // in drop down
  *                         ]);
  *
  *          $this->setProviders('vkontakte=true,odnoklassniki=true,mailru=true,openid=false');
  *          </code>
  * @return Init
  */
 public function setProviders($providers)
 {
     $array = Parser::map($providers);
     // collection data
     if (empty($array['required']) === false) {
         $this->requiredProviders = implode(',', $array['required']);
     }
     if (empty($array['hidden']) === false) {
         $this->hiddenProviders = implode(',', $array['hidden']);
     }
     return $this;
 }
コード例 #2
0
 /**
  * @covers ULogin\Parser::stringResolve()
  * @covers ULogin\Parser::isDelim()
  * @covers ULogin\Parser::separate()
  */
 public function testStringResolve()
 {
     // test empty param
     $result = Parser::stringResolve();
     $this->assertInternalType('array', $result, "[-] Return type of stringResolve() must be array if was injected string");
     $this->assertArrayHasKey('required', $result, "[-] stringResolve() method should return array with key [required]");
     // some true data
     $resultTrue = Parser::stringResolve('vk=true,linkedin=true,mailru=false');
     $this->assertCount(2, $resultTrue, "[-] The number of elements array produced by method stringResolve() must count 2");
     $this->assertArrayHasKey('hidden', $resultTrue, "[-] stringResolve() method should return array with key [hidden]");
     $this->assertArrayHasKey('required', $resultTrue, "[-] stringResolve() method should return array with key [required]");
     $resultWithoutDelim = Parser::stringResolve('vk,linkedin,mailru');
     $this->assertInternalType('array', $resultWithoutDelim, "[-] Return type of stringResolve() must be array if was injected string");
     $this->assertArrayHasKey('required', $resultWithoutDelim, "[-] stringResolve() method should return array with key [required]");
 }