This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Mohsin
Mohsin

I’m writing RESTful APIs using OctoberCMS, and it’s great. But I seemed to have hit a roadblock, how exactly am I supposed to write network test operations? I’ve tried checking the OctoberCMS documentation and it doesn’t suggest anything. The laravel docs suggest this but when I use the call method from within a plugin test like this:

$response = $this->call('POST', '/api/v1/post’, [’title’ => ’Some random article']);

And I get this error

ErrorException: Undefined property: Acme\Blog\Tests\PostTest::$baseUrl

Basically my goal is to write test cases so I can impersonate Http requests and then the API would actually create the data in the Db and then I just verify if that’s exactly the expected output. Any ideas on how I can do this?

OFFLINE
OFFLINE

Did you extend the TestCase class in your own test class?

class YourTest extends TestCase {
}
Mohsin
Mohsin

No since this is a plugin test I followed the steps provided here and instead extended PluginTestCase like this:

class PostTest extends PluginTestCase
{
}

I believe this should be fine considering that PluginTestCase seems to extend Illuminate\Foundation\Testing\TestCase

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.