aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Lib/ZotlibTest.php
blob: 05522678f134bd24650e032833ef4c7c21206963 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
class LibzotTest extends \Zotlabs\Tests\Unit\UnitTestCase {
	/**
	 * Test the `get_rpost_path` function.
	 *
	 * @dataProvider get_rpost_path_provider
	 */
	public function test_get_rpost_path(string $expected, string $xchan_url) : void {
		$observer = [ 'xchan_url' => $xchan_url ];

		$this->assertEquals($expected, \Zotlabs\Lib\Libzot::get_rpost_path($observer));
	}

	private function get_rpost_path_provider() : array {
		return [
			'xchan_url without port' => [
				'https://example.com/rpost?f=',
				'https://example.com'
			],
			'xchan_url with port' => [
				'https://example.com:666/rpost?f=',
				'https://example.com:666'
			],
			'xchan_url ignores path and args' => [
				'https://example.com/rpost?f=',
				'https://example.com/path?arg1=balle'
			],
			'xchan_url with no scheme should default to https' => [
				'https://example.com/rpost?f=',
				'example.com',
			],
		];
	}
}