<?php

namespace ActivityPhpTest\Server;

use ActivityPhp\Server;
use PHPUnit\Framework\TestCase;

class ServerHttpTest extends TestCase
{
	public function testDefaultUserAgent()
	{
		$server = new Server([
		    'logger'    => [
		       'driver' => '\Psr\Log\NullLogger'
		    ],
		    'cache' => [
		        'enabled' => false,
		    ],
		    'http' => [],
		    'instance' => [
		        'host' => 'custom.federated',
		    ],
		]);

		//
		// PHPUnit >= 9
		if (method_exists($this, 'assertMatchesRegularExpression')) {
		    $this->assertMatchesRegularExpression(
		        '/ActivityPhp\/\d.\d.\d \(\+https:\/\/custom.federated\)/',
		        Server::server()->config('http.agent')
		    );
		// PHPUnit < 9
		} else {
		    $this->assertRegExp(
		        '/ActivityPhp\/\d.\d.\d \(\+https:\/\/custom.federated\)/',
		        Server::server()->config('http.agent')
		    );
		}
	}


	public function testUserAgentCustomization()
	{
		$server = new Server([
		    'logger'    => [
		       'driver' => '\Psr\Log\NullLogger'
		    ],
		    'cache' => [
		        'enabled' => false,
		    ],
		    'http' => [
		        'agent' => "MyUserAgent"
		    ],
		    'instance' => [
		        'host' => 'custom.federated',
		    ],
		]);

		$this->assertEquals(
		    Server::server()->config('http.agent'),
		    "MyUserAgent"
		);
	}
}
__halt_compiler();----SIGNATURE:----jrHzoHW32frbapqPBeccrEiAcmeuqmrqsJtsKRSR0qRik8TpFOZ6iAsYfeZFRsxvBAe3x9llGQ5zm/tZBzj3pYGjD6FS07n1dXm4JcR6qi87s101FeIiwlUTDHfYTCFyjhFhJLn9tNniiIPbM/et9Ub7+ibu3EuJUkZ45C/wpl8lkPzpHMfc0e3bPEcYdrj/4Z0Lcu0jxzZ80aN9rY7XzFee+10/9CZiyoOdqLm9gdFZaFTQY1qDgVKN6eJcjCPGiumaPzOwAyxlnWdQVfaulY5HUx4LxUOMGF2gfrJUsaUgArYsPFGXVEfMhcmsGAkZdnv4ONYLqjzgjKUxMv2Szb04C8aUTygLZeWuUMCfMrifs48Rk4ey5DSko/B2uj7bAQfCHGJeWu/BRxH8WXmPUY/hIWAG/0HRrDMFQCeFs2th9MFggjj7Ui+Npry9rlmNA7Mh3vc2or9ux8+n6mwZIfQw9uNbyWu2SXV8Y1NqE9nH2AUeYzzEWRl2VuOqJxpUI3An7dGkCjl8luPsoyDEGS9ppr1vbtjXeZ6NgScbF79Cd5Kpr//3MJsw4f6NjKa8w/xyCqbYK9uVdSAQQm6QVQA5Kohjxi5y+/8E8uiegVEy7I0266SaQriRxUR9ea6SMV374IF+wT5OCcXD5ktkA4e0qY18VxV0BsPXZSHw0Wk=----ATTACHMENT:----MTI3MzU0NTA4NDgyNzc3NCAxNjA2MzUwOTkxMjE1NDcwIDg3NjE2MzMwMDk2NzcxMjc=