public function testSecret()
 {
     $twofactorAdapter = new twofactorAdapter();
     $this->assertTrue($twofactorAdapter->check($twofactorAdapter->getCode()));
     $twofactorAdapter2 = new twofactorAdapter();
     $twofactorAdapter2->setSecret($twofactorAdapter->getSecret());
     $this->assertEquals($twofactorAdapter2->getSecret(), $twofactorAdapter->getSecret());
     $this->assertTrue($twofactorAdapter2->check($twofactorAdapter->getCode()));
     $this->assertEquals($twofactorAdapter2->getCode(), $twofactorAdapter->getCode());
     $twofactorAdapter2->setSecret("XVQ2UIGO75XRUKJO");
     $this->assertNotEquals($twofactorAdapter2->getSecret(), $twofactorAdapter->getSecret());
     $this->assertFalse($twofactorAdapter2->check($twofactorAdapter->getCode()));
     $this->assertTrue($twofactorAdapter2->check($twofactorAdapter2->getCode()));
     $this->assertNotEquals($twofactorAdapter2->getCode(), $twofactorAdapter->getCode());
 }
 public function __construct($dir = ".", $cookieCode = "", $serviceName = "none")
 {
     if ($cookieCode == "") {
         $cookieCode = md5(rand());
     }
     $this->dir = $dir;
     $this->cookieCode = $cookieCode;
     $this->twofactorAdapter = new twofactorAdapter();
     $this->twofactorAdapter->setDir($this->dir);
     $this->twofactorAdapter->setServiceName($serviceName);
     $secret = $this->readSecret();
     if ($secret && $secret != 1) {
         //I have a secret stored, so I set it as secret
         $this->twofactorAdapter->setSecret($secret);
     } else {
         //I don't have a secret stored so I store the secret generated by library
         $this->storeSecret($this->twofactorAdapter->getSecret());
     }
     $this->secret = $this->twofactorAdapter->getSecret();
 }