Restructuring API method for testing

Description

At the moment, quite a few API methods have header() and exit; calls within them that make it hard to write tests.

As a temporary workaround we've used constants to change the return value for tests, but obviously this isn't a long term solution.

We need to look at re-factoring these methods to make them testable - most likely that would involve moving the header setting and exit out into a separate class that can then be mocked for testing.

@heiglandreas has started with this in https://github.com/joindin/joindin-api/pull/360/, so we need to check if that is the way we want to go (mostly, can it be extended to support cases where we currently use exit [i.e. header with no body], and do we want to use the existing view class for it, and does that then require any additional mocking?)

Status

Assignee

Andreas Heigl

Reporter

Liam

Labels

None

Epic Name <span class="error">&#91;deprecated, this field is no longer being used&#93;</span>

None

Components

Priority

Major