_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data'; if (!is_dir($this->_path)) { mkdir($this->_path); } $this->_file = $this->_path . DIRECTORY_SEPARATOR . 'vizhash.png'; ServerSalt::setPath($this->_path); } public function tearDown() { /* Tear Down Routine */ chmod($this->_path, 0700); Helper::rmDir($this->_path); } public function testVizhashGeneratesPngs() { $this->forAll( Generator\string(), Generator\string() )->then( function ($string1, $string2) { $vz = new Vizhash16x16(); $pngdata = $vz->generate($string1); if (empty($string1)) { $this->assertEquals($pngdata, ''); } else { $this->assertNotEquals($pngdata, ''); file_put_contents($this->_file, $pngdata); $finfo = new finfo(FILEINFO_MIME_TYPE); $this->assertEquals('image/png', $finfo->file($this->_file)); if ($string1 !== $string2) { $this->assertNotEquals($pngdata, $string2); } } $this->assertEquals($pngdata, $vz->generate($string1)); } ); } public function testVizhashGeneratesUniquePngsPerIp() { $vz = new Vizhash16x16(); $pngdata = $vz->generate(hash('sha512', '127.0.0.1')); file_put_contents($this->_file, $pngdata); $finfo = new finfo(FILEINFO_MIME_TYPE); $this->assertEquals('image/png', $finfo->file($this->_file)); $this->assertNotEquals($pngdata, $vz->generate(hash('sha512', '2001:1620:2057:dead:beef::cafe:babe'))); $this->assertEquals($pngdata, $vz->generate(hash('sha512', '127.0.0.1'))); } }