# Laminas-test dispatch url with Hostname in route

**URL:** <https://discourse.laminas.dev/t/laminas-test-dispatch-url-with-hostname-in-route/1910>\
**Category:** Components & MVC\
**Tags:** laminas-mvc\
**Created:** [October 24, 2020, 5:18pm UTC](https://discourse.laminas.dev/t/laminas-test-dispatch-url-with-hostname-in-route/1910 "2020-10-24T17:18:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbuerli](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tbuerli/32/821_2.png) [@tbuerli](https://discourse.laminas.dev/u/tbuerli)\
**Post date:** [October 24, 2020, 5:18pm UTC](https://discourse.laminas.dev/t/laminas-test-dispatch-url-with-hostname-in-route/1910/1 "2020-10-24T17:18:14Z")

</div>

I made quite positive experiences with the laminas testing environment. It’s quite useful to be able to dispatch a path and check if the correct route/controller was triggered.

> **[Unit testing with PHPUnit - laminas-test - Laminas Docs](https://docs.laminas.dev/laminas-test/phpunit/)**
>
> laminas-test

But when I added a top level Route with a Hostname I got a lot of trouble with testing. I can open the Pages with a Web browser, but don’t know how I should define it for the testing environment to use a Domain not just a path.

I tried already:

```auto
$this->dispatch('abc.local/some', 'GET');

```

```auto
$this->getRequest()->setBaseUrl("abc.local");
$this->dispatch('/some', 'GET');

```

Router Definition:

```auto
'router' => [
        'routes' => [
            'abc' => [
                'type' => Hostname::class,
                'options' => [
                    'route' => '[:subdomain.]:domain.:tld',
                    'defaults' => [
                        'tld' => 'local',
                        'domain' => 'abc',
                    ],
                    'constraints' => [
                        'tld' => '(ch|local)',
                        'domain' => 'abc',
                    ]
                ],
                'child_routes' => [
                    'home' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/[:action]',
                            'defaults' => [
                                'controller' => Controller\IndexController::class,
                                'action' => 'index',
                            ],
                            'constraints' => [
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
],

```
