aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/includes/NetworkTest.php
blob: 0b9b42e002ff0d1492a1d536d9423d71337c042e (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
<?php
/**
 * tests function from include/network.php
 *
 * @package test.util
 */

use PHPUnit\Framework\TestCase;

require_once('include/network.php');

class NetworkTest extends TestCase {

  public function setup() : void {
    \App::set_baseurl("https://mytest.org");
  }

  /**
   * @dataProvider localUrlTestProvider
   */
  public function testIsLocalURL($url, $expected) {
    $this->assertEquals($expected, is_local_url($url));
  }

  public function localUrlTestProvider() : array {
    return [
      [ '/some/path', true ],
      [ 'https://mytest.org/some/path', true ],
      [ 'https://other.site/some/path', false ],
    ];
  }
}