October: PHP Unit received status code [404] on exists page.

Created on 2 Nov 2016  路  5Comments  路  Source: octobercms/october

Hi, I'm trying to run a simple test in my project. I'm trying to visit post page and ensure the some words is exists on that page.

But, I got the the following error when run this command ./vendor/bin/phpunit tests/ExampleTest.php;

1) ExampleTest::testBasicExample
A request to [http://testing.dev/post] failed. Received status code [404].

I know exactly when access that url with browser the page is exists.

Here's my code:

_pages/post.htm_

url = "/post"
==
<h1>Welcome to post details page!</h1>

_tests/ExampleTest.php_

<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class ExampleTest extends TestCase 
{

    protected $baseUrl = 'http://testing.dev';

    public function testBasicExample()
    {
        $this->visit('/post')
             ->see('Welcome to post details page!');
    }
}

OctoberCMS Build 376

Thanks

High Review Needed Unconfirmed Bug

All 5 comments

Interesting. We need someone to peer review this to confirm.

I tried something similar to unit test plugin routes and got 500 status code with message Class user.auth does not exist in file /Users/Moz/Projects/Current/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php.

Testing on OctoberCMS needs more documentation methinks.

@SaifurRahmanMohsin, help us help you. Please report a new issue instead of hijacking others. Here is how you can report an issue that we can use to help:

As per the contribution guidelines, please provide the exact steps you are taking for the issue to occur. This will be used for peer review.

Here is an example of a bug summary:

The CMS page URL is not being set automatically from the title value.

Here is an example of some reproduce steps:

  1. In the back-end, open the CMS > Pages section
  2. Click the "Add" button
  3. Enter [Hello] for the Title field
  4. Click the Save button

Here is an example of expected behavior:

  • The Title should be set to [Hello]
  • The URL should be set to [/hello]

Here is an example of actual behavior:

  • The Title is set to [Hello] correctly
  • The URL is left empty

Finally, I can solve this issue. It because I didn't configure the config/testing/cms.php with my existing theme and correct path. Hopefully for the next, testing in OctoberCMS more documented.

Thank you, @daftspunk. I love OctoberCMS!

No probs! You shouldn't need to update this configuration setting, although it is possible. Perhaps using Config::set('cms.activeTheme', 'mytheme'); before the test runs would be suitable.

Was this page helpful?
0 / 5 - 0 ratings