FOSSology  4.5.1
Open Source License Compliance by Open Source Software
InfoTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2020 Siemens AG
4  Author: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
14 
17 
22 class InfoTest extends \PHPUnit\Framework\TestCase
23 {
25 
31  public function testConstructor()
32  {
33  $info = new Info(200, "All good", InfoType::INFO);
34  $this->assertInstanceOf(Info::class, $info);
35  }
36 
41  public function testDataFormat()
42  {
43  $expectedInfo = [
44  'code' => 200,
45  'message' => "All good",
46  'type' => "INFO"
47  ];
48  $expectedError = [
49  'code' => 500,
50  'message' => "Something bad",
51  'type' => "ERROR"
52  ];
53 
54  $actualInfo = new Info(200, "All good", InfoType::INFO);
55  $actualError = new Info(500, "Something bad", InfoType::ERROR);
56 
57  $this->assertEquals($expectedInfo, $actualInfo->getArray());
58  $this->assertEquals($expectedError, $actualError->getArray());
59  }
60 }
Different type of infos provided by REST.
Definition: InfoType.php:16
Info model to contain general error and return values.
Definition: Info.php:19