2 declare(strict_types = 1);
19 use Prophecy\Argument;
24 use TYPO3\CMS\Install\Service\CoreVersionService;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
40 $requestFactory = $this->prophesize(RequestFactory::class);
41 $requestFactory->request(
'https://get.typo3.org/v1/api/' . $url, Argument::cetera())->willReturn($response);
42 GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());
54 'title' =>
'TYPO3 v9',
55 'release_date' =>
'2018-01-30T00:00:00+01:00',
59 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
60 $instance->expects(self::once())->method(
'getInstalledMajorVersion')->willReturn(
'9');
62 $result = $instance->getMaintenanceWindow()->isSupportedByCommunity();
64 self::assertFalse($result);
76 'title' =>
'TYPO3 v9',
77 'release_date' =>
'2018-01-30T00:00:00+01:00',
78 'maintained_until' =>
'2222-01-30T00:00:00+01:00',
82 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
83 $instance->expects(self::once())->method(
'getInstalledMajorVersion')->willReturn(
'9');
85 $result = $instance->getMaintenanceWindow()->isSupportedByCommunity();
87 self::assertTrue($result);
99 'title' =>
'TYPO3 v7',
100 'maintained_until' =>
'2003-02-18T08:10:14+00:00',
101 'release_date' =>
'2002-06-03T12:01:07+00:00',
105 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
106 $instance->expects(self::once())->method(
'getInstalledMajorVersion')->willReturn(
'7');
108 $result = $instance->getMaintenanceWindow()->isSupportedByCommunity();
110 self::assertFalse($result);
122 'title' =>
'TYPO3 v9',
123 'release_date' =>
'2018-01-30T00:00:00+01:00',
127 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
128 $instance->expects(self::once())->method(
'getInstalledMajorVersion')->willReturn(
'9');
130 $result = $instance->getMaintenanceWindow()->isSupportedByElts();
132 self::assertFalse($result);
144 'title' =>
'TYPO3 v9',
145 'release_date' =>
'2018-01-30T00:00:00+01:00',
146 'elts_until' =>
'2222-01-30T00:00:00+01:00',
150 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
151 $instance->expects(self::once())->method(
'getInstalledMajorVersion')->willReturn(
'9');
153 $result = $instance->getMaintenanceWindow()->isSupportedByElts();
155 self::assertTrue($result);
167 'title' =>
'TYPO3 v7',
168 'maintained_until' =>
'2003-02-18T08:10:14+00:00',
169 'elts_until' =>
'2002-06-03T12:01:07+00:00',
173 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
174 $instance->expects(self::once())->method(
'getInstalledMajorVersion')->willReturn(
'7');
176 $result = $instance->getMaintenanceWindow()->isSupportedByElts();
178 self::assertFalse($result);
192 'title' =>
'TYPO3 11',
193 'maintained_until' => (
new \DateTimeImmutable(
'+3 years'))->format(\DateTimeInterface::ATOM),
194 'elts_until' => (
new \DateTimeImmutable(
'+ 6 years'))->format(\DateTimeInterface::ATOM),
198 'title' =>
'TYPO3 10 LTS',
199 'maintained_until' => (
new \DateTimeImmutable(
'+2 years'))->format(\DateTimeInterface::ATOM),
200 'elts_until' => (
new \DateTimeImmutable(
'+ 5 years'))->format(\DateTimeInterface::ATOM),
205 'title' =>
'TYPO3 9 LTS',
206 'maintained_until' => (
new \DateTimeImmutable(
'+2 months'))->format(\DateTimeInterface::ATOM),
207 'elts_until' => (
new \DateTimeImmutable(
'+3 years'))->format(\DateTimeInterface::ATOM),
212 'title' =>
'TYPO3 8 ELTS',
213 'maintained_until' => (
new \DateTimeImmutable(
'-1 year'))->format(\DateTimeInterface::ATOM),
214 'elts_until' => (
new \DateTimeImmutable(
'+2 years'))->format(\DateTimeInterface::ATOM),
219 'title' =>
'TYPO3 7 ELTS',
220 'maintained_until' => (
new \DateTimeImmutable(
'-3 years'))->format(\DateTimeInterface::ATOM),
221 'elts_until' => (
new \DateTimeImmutable(
'+2 months'))->format(\DateTimeInterface::ATOM),
226 'title' =>
'TYPO3 6 ELTS',
227 'maintained_until' => (
new \DateTimeImmutable(
'-4 years'))->format(\DateTimeInterface::ATOM),
228 'elts_until' => (
new \DateTimeImmutable(
'-5 months'))->format(\DateTimeInterface::ATOM),
234 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'dummy']);
235 $result = $instance->getSupportedMajorReleases();
238 'community' => [
'11',
'10.4',
'9.5'],
239 'elts' => [
'8.7',
'7.6'],
241 self::assertSame($expectation, $result);
250 'major/9/release/latest',
252 'version' =>
'9.1.0',
253 'date' =>
'2018-01-30T15:44:52+00:00',
256 'sha1sum' =>
'3a277826d716eb4e82a36a2200deefd76d15378c'
261 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledVersion',
'getInstalledMajorVersion']);
262 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn(
'9');
263 $instance->expects(self::atLeastOnce())->method(
'getInstalledVersion')->willReturn(
'9.0.0');
265 $coreRelease = $instance->getYoungestPatchRelease();
266 $result = $instance->isPatchReleaseSuitableForUpdate($coreRelease);
268 self::assertTrue($result);
277 'major/9/release/latest',
279 'version' =>
'9.1.0',
280 'date' =>
'2018-01-30T15:44:52+00:00',
283 'sha1sum' =>
'3a277826d716eb4e82a36a2200deefd76d15378c'
288 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledVersion',
'getInstalledMajorVersion']);
289 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn(
'9');
290 $instance->expects(self::atLeastOnce())->method(
'getInstalledVersion')->willReturn(
'9.1.0');
292 $coreRelease = $instance->getYoungestPatchRelease();
293 $result = $instance->isPatchReleaseSuitableForUpdate($coreRelease);
295 self::assertFalse($result);
303 $coreRelease =
new CoreRelease(
'8.7.5',
new \DateTimeImmutable(
'2017-09-05T10:54:18+00:00'),
'security',
'e79466bffc81f270f5c262d01a125e82b2e1989a');
309 'version' =>
'8.7.1',
310 'date' =>
'2017-04-18T17:05:53+00:00',
313 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
317 'version' =>
'8.7.4',
318 'date' =>
'2017-07-25T16:47:27+00:00',
321 'sha1sum' =>
'1129c740796aabbf2efbc5e43f892debe7e1d583',
325 'version' =>
'8.7.5',
326 'date' =>
'2017-09-05T10:54:18+00:00',
327 'type' =>
'security',
329 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
335 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledVersion',
'getInstalledMajorVersion']);
336 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn(
'8');
337 $instance->expects(self::atLeastOnce())->method(
'getInstalledVersion')->willReturn(
'8.7.1');
339 $result = $instance->isUpdateSecurityRelevant($coreRelease);
341 self::assertTrue($result);
349 $coreRelease =
new CoreRelease(
'8.7.6',
new \DateTimeImmutable(
'2017-09-05T10:54:18+00:00'),
'security',
'e79466bffc81f270f5c262d01a125e82b2e1989a');
355 'version' =>
'8.7.5',
356 'date' =>
'2017-09-05T10:54:18+00:00',
357 'type' =>
'security',
359 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
363 'version' =>
'8.7.6',
364 'date' =>
'2017-09-05T10:54:18+00:00',
367 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
371 'version' =>
'8.7.33',
372 'date' =>
'2020-05-12T00:00:00+02:00',
373 'type' =>
'security',
375 'sha1sum' =>
'2dd44ab6c98c3f07a0bbe4af6ccc5d7ced7e5856',
381 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledVersion',
'getInstalledMajorVersion']);
382 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn(
'8');
383 $instance->expects(self::atLeastOnce())->method(
'getInstalledVersion')->willReturn(
'8.7.5');
385 $result = $instance->isUpdateSecurityRelevant($coreRelease);
387 self::assertFalse($result);
395 $coreRelease =
new CoreRelease(
'8.7.6',
new \DateTimeImmutable(
'2017-09-05T10:54:18+00:00'),
'security',
'e79466bffc81f270f5c262d01a125e82b2e1989a');
401 'version' =>
'8.7.5',
402 'date' =>
'2017-09-05T10:54:18+00:00',
403 'type' =>
'security',
405 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
409 'version' =>
'8.7.6',
410 'date' =>
'2017-09-05T10:54:18+00:00',
413 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
419 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledVersion',
'getInstalledMajorVersion']);
420 $instance->expects(self::atLeastOnce())->method(
'getInstalledVersion')->willReturn(
'8.7.5');
421 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn(
'8');
423 $result = $instance->isUpdateSecurityRelevant($coreRelease);
425 self::assertFalse($result);
438 'version' =>
'8.7.1',
439 'date' =>
'2017-04-18T17:05:53+00:00',
443 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
447 'version' =>
'8.7.4',
448 'date' =>
'2017-07-25T16:47:27+00:00',
452 'sha1sum' =>
'1129c740796aabbf2efbc5e43f892debe7e1d583',
456 'version' =>
'8.7.33',
457 'date' =>
'2020-05-12T00:00:00+02:00',
458 'type' =>
'security',
461 'sha1sum' =>
'2dd44ab6c98c3f07a0bbe4af6ccc5d7ced7e5856',
467 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion',
'getInstalledVersion']);
468 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn($major);
469 $instance->expects(self::atLeastOnce())->method(
'getInstalledVersion')->willReturn($version);
471 self::assertSame($expectation, $instance->isCurrentInstalledVersionElts());
477 [
'8',
'8.7.4',
false],
478 [
'8',
'8.7.33',
true]
489 'major/' . $major .
'/release/latest',
493 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
494 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn($major);
496 $result = $instance->getYoungestPatchRelease();
498 self::assertSame($response[
'version'], $result->getVersion());
499 self::assertEquals($response[
'date'], $result->getDate()->format(\DateTimeInterface::ATOM));
500 self::assertSame($response[
'type'] ===
'security', $result->isSecurityUpdate());
501 self::assertEquals($response[
'tar_package'][
'sha1sum'], $result->getChecksum());
502 self::assertSame($response[
'elts'], $result->isElts());
511 'version' =>
'9.1.0',
512 'date' =>
'2018-01-30T15:44:52+00:00',
516 'sha1sum' =>
'3a277826d716eb4e82a36a2200deefd76d15378c',
523 'version' =>
'8.7.33',
524 'date' =>
'2020-05-12T00:00:00+02:00',
525 'type' =>
'security',
528 'sha1sum' =>
'2dd44ab6c98c3f07a0bbe4af6ccc5d7ced7e5856',
544 'version' =>
'8.7.1',
545 'date' =>
'2017-04-18T17:05:53+00:00',
549 'sha1sum' =>
'e79466bffc81f270f5c262d01a125e82b2e1989a',
553 'version' =>
'8.7.4',
554 'date' =>
'2017-07-25T16:47:27+00:00',
558 'sha1sum' =>
'1129c740796aabbf2efbc5e43f892debe7e1d583',
562 'version' =>
'8.7.30',
563 'date' =>
'2019-12-17T10:51:34+01:00',
564 'type' =>
'security',
567 'sha1sum' =>
'3df3a112dc7e2857bf39cfd2bc2c0bb7842a824c',
571 'version' =>
'8.7.33',
572 'date' =>
'2020-05-12T00:00:00+02:00',
573 'type' =>
'security',
576 'sha1sum' =>
'2dd44ab6c98c3f07a0bbe4af6ccc5d7ced7e5856',
582 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledMajorVersion']);
583 $instance->expects(self::atLeastOnce())->method(
'getInstalledMajorVersion')->willReturn(
'8');
585 $result = $instance->getYoungestCommunityPatchRelease();
587 self::assertSame(
'8.7.30', $result->getVersion());
596 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledVersion'], [],
'',
false);
597 $instance->expects(self::once())->method(
'getInstalledVersion')->willReturn(
'7.2.0');
598 self::assertTrue($instance->isInstalledVersionAReleasedVersion());
607 $instance = $this->getAccessibleMock(CoreVersionService::class, [
'getInstalledVersion'], [],
'',
false);
608 $instance->expects(self::once())->method(
'getInstalledVersion')->willReturn(
'7.4-dev');
609 self::assertFalse($instance->isInstalledVersionAReleasedVersion());