function it_returns_the_latest_version_if_the_requested_version_is_invalid(Request $request, \LaraPackage\Api\Contracts\Config\ApiVersion $version) { $this->requestHeaderExpectation($request, 'application/vnd.wps_api.v500012+json'); $version->isValid(500012)->shouldBeCalledTimes(1)->willReturn(false); $version->latest()->shouldBeCalledTimes(1)->willReturn(4); $this->version()->shouldReturn(4); }
/** * @param string $string * * @return int */ protected function parseVersion($string) { $version = \preg_replace('/[^0-9]/', '', $string); if (!is_numeric($version)) { return (int) $this->version->latest(); } return (int) $version; }