hostTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use ProfiCloS\VestaCP\Authorization\Credentials;
  3. use ProfiCloS\VestaCP\Authorization\Host;
  4. require_once __DIR__ . '/../vendor/autoload.php';
  5. class hostTest extends \PHPUnit\Framework\TestCase
  6. {
  7. public function testHost()
  8. {
  9. $credentials = new Credentials('', '');
  10. $host = new Host('', $credentials);
  11. $this->assertSame('', $host->getHostname());
  12. $host->setHostname('host');
  13. $this->assertSame('host', $host->getHostname());
  14. }
  15. public function testUri()
  16. {
  17. $credentials = new Credentials('', '');
  18. $host = new Host('https://vesta', $credentials);
  19. $this->assertSame('https://vesta:8083/api/', $host->buildUri());
  20. }
  21. public function testPort()
  22. {
  23. $credentials = new Credentials('', '');
  24. $host = new Host('', $credentials);
  25. $this->assertSame(8083, $host->getPort());
  26. $host->setPort(2023);
  27. $this->assertSame(2023, $host->getPort());
  28. }
  29. public function testCredentials()
  30. {
  31. $credentials = new Credentials('', '');
  32. $host = new Host('', $credentials);
  33. $this->assertSame($credentials, $host->getCredentials());
  34. $newCredentials = new Credentials('', '');
  35. $host->setCredentials($newCredentials);
  36. $this->assertNotSame($credentials, $host->getCredentials());
  37. $this->assertSame($newCredentials, $host->getCredentials());
  38. }
  39. }