title: phpunit how to test a method which uses the browser url
body: <p>I have the following methods:</p>
  
  <pre><code>public function isAdmin()
  {
      $adminUrl = $this-&gt;getPage(2)-&gt;httpUrl;
      /*
       * Remove all segments except the first in the URL path
       * to detect if current page is in admin view
       */
      $currentUrl = preg_replace( // https://regex101.com/r/D0mOz9/1
          sprintf(
              '~(?&lt;adminUrl&gt;%s)(?&lt;remove&gt;.*)$~',
              addslashes($adminUrl)
          ),
          '$1',
          $this-&gt;getPage()-&gt;httpUrl
      );
      return $adminUrl == $currentUrl || (!$currentUrl &amp;&amp; !$this-&gt;getPage() instanceof NullPage);
  }
  public function getPage($page = null)
  {
      $wiredPage = $this-&gt;wire('page');
      if (!is_null($wiredPage) &amp;&amp; is_null($page)) {
          $baseUrl = $this-&gt;wire('page')-&gt;url;
          $urlSegmentStr = $this-&gt;wire('input')-&gt;urlSegmentStr;
          if (strlen($urlSegmentStr)) {
              $baseUrl = rtrim($baseUrl, '/') . "/$urlSegmentStr/";
          }
          return $this-&gt;pages-&gt;get($baseUrl);
      }
  
      if (is_null($page)) {
          return $this-&gt;pages-&gt;get(parse_url(getenv('REQUEST_URI'), PHP_URL_PATH));
      }
  
      return $this-&gt;pages-&gt;get($page);
  }
  </code></pre>
  
  <p>I check if for an admin page by getting the url to the admin page and compare it to the current url.
  Now I want to write a test for it with PHPunit but I have no idea how to test a method which result is based on urls like this.
  Is it possible to write a test for a case like this? How would I be able to do this?</p>