torExecutableDir = __DIR__ . '/../tor-client/bin'; $this->torExecutableFailureDir = '/'; } public function testLocatorSuccess() { $locator = new TorLocator($this->torExecutableDir); $torBinary = $locator->getBinary(); $testBinary = new \SplFileInfo(__DIR__ . '/../tor-client/bin/tor'); $this->assertSame($testBinary->getRealPath(), $torBinary->getRealPath()); $this->assertSame(__DIR__ . '/../tor-client/bin', $torBinary->getPath()); $this->assertSame(__DIR__ . '/../tor-client/bin/tor', $torBinary->getPathname()); $this->assertTrue($torBinary->isExecutable(), true); } public function testLocatorAutoResolveSuccess() { $locator = new TorLocator(); $torBinary = $locator->getBinary(); $this->assertSame('/usr/bin/tor', $torBinary->getPathname()); } public function testLocatorFailureWithCatch() { try { $locator = new TorLocator($this->torExecutableFailureDir); $torBinary = $locator->getBinary(); } catch(\Exception $e) { $this->assertSame('Couldn\'t find the tor binary.', $e->getMessage()); } } /** * @expectedException \Exception */ public function testLocatorFailure() { $locator = new TorLocator($this->torExecutableFailureDir); $torBinary = $locator->getBinary(); } }