FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ApiVersionTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  SPDX-FileCopyrightText: © 2024 Valens Niyonsenga <valensniyonsenga2003@gmail.com>
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 
14 
16 use PHPUnit\Framework\TestCase;
17 use Psr\Http\Message\ServerRequestInterface;
18 
19 class ApiVersionTest extends TestCase
20 {
25  {
26  $requestMock = $this->createMock(ServerRequestInterface::class);
27  $requestMock->method('getAttribute')
28  ->with(ApiVersion::ATTRIBUTE_NAME, ApiVersion::V1)
29  ->willReturn(ApiVersion::V2);
30 
31  $this->assertEquals(ApiVersion::V2, ApiVersion::getVersion($requestMock));
32  }
33 
38  {
39  $requestMock = $this->createMock(ServerRequestInterface::class);
40  $requestMock->method('getAttribute')
41  ->with(ApiVersion::ATTRIBUTE_NAME, ApiVersion::V1)
42  ->willReturn(ApiVersion::V1);
43 
44  $this->assertEquals(ApiVersion::V1, ApiVersion::getVersion($requestMock));
45  }
46 }
static getVersion(ServerRequestInterface $request)
Definition: ApiVersion.php:29