16 use PHPUnit\Framework\TestCase;
34 protected function setUp(): void
38 'filename' =>
'test.txt',
39 'description' =>
'Test file'
44 'mime_type' =>
'text/plain',
45 'last_modified' =>
'2025-02-15'
48 $this->packageInfo = [
49 'name' =>
'test-package',
51 'license' =>
'GPL-2.0'
60 'reuse_status' =>
'yes',
61 'reuse_text' =>
'Can be reused'
82 $this->assertInstanceOf(FileInfo::class, $fileInfo);
101 $result = $fileInfo->getArray(ApiVersion::V1);
104 'view_info' => $this->viewInfo,
105 'meta_info' => $this->metaInfo,
106 'package_info' => $this->packageInfo,
107 'tag_info' => $this->tagInfo,
108 'reuse_info' => $this->reuseInfo
111 $this->assertEquals($expectedArray, $result);
128 $result = $fileInfo->getArray(ApiVersion::V2);
131 'viewInfo' => $this->viewInfo,
132 'metaInfo' => $this->metaInfo,
133 'packageInfo' => $this->packageInfo,
134 'tagInfo' => $this->tagInfo,
135 'reuseInfo' => $this->reuseInfo
138 $this->assertEquals($expectedArray, $result);
155 $result = $fileInfo->getJSON(ApiVersion::V1);
157 $this->assertIsString($result);
158 $this->assertJson($result);
160 $decodedJson = json_decode($result,
true);
161 $this->assertEquals($fileInfo->getArray(ApiVersion::V1), $decodedJson);
178 $result = $fileInfo->getJSON(ApiVersion::V2);
180 $this->assertIsString($result);
181 $this->assertJson($result);
183 $decodedJson = json_decode($result,
true);
184 $this->assertEquals($fileInfo->getArray(ApiVersion::V2), $decodedJson);
FileInfo model to contain general error and return values.
Tests for FileInfo model.