/**
  * Check behaviour of `Bcrypt::salt()`.
  *
  * @return void
  */
 public function testSalt()
 {
     // hashes used for one time only, well, two times :)
     $salt1 = Bcrypt::salt();
     $salt2 = Bcrypt::salt(4);
     $salt3 = Bcrypt::salt(5);
     $salt4 = Bcrypt::salt(10);
     $salt5 = Bcrypt::salt(11);
     $salt6 = Bcrypt::salt(31);
     // lenght
     $this->assertEquals(29, strlen($salt1));
     $this->assertEquals(29, strlen($salt2));
     $this->assertEquals(29, strlen($salt3));
     $this->assertEquals(29, strlen($salt4));
     $this->assertEquals(29, strlen($salt5));
     $this->assertEquals(29, strlen($salt6));
     // anonymous helper function
     $sub = function ($salt) {
         return substr($salt, 0, 7);
     };
     // check iteration
     $this->assertEquals(sprintf($this->_prefix() . '%02d$', Bcrypt::DEFAULT_ITERATION_COUNT), $sub($salt1));
     $this->assertEquals($this->_prefix() . '04$', $sub($salt2));
     $this->assertEquals($this->_prefix() . '05$', $sub($salt3));
     $this->assertEquals($this->_prefix() . '10$', $sub($salt4));
     $this->assertEquals($this->_prefix() . '11$', $sub($salt5));
     $this->assertEquals($this->_prefix() . '31$', $sub($salt6));
     // test invalid iteration count
     foreach (array(0, 3, 32, 1337) as $i) {
         try {
             Bcrypt::salt($i);
             $message = 'InvalidArgumentException should have been thrown for $i = ' . $i;
             $this->fail($message);
         } catch (InvalidArgumentException $e) {
         }
         // free it
         $i = null;
         unset($i);
     }
 }