Skip to content

Commit

Permalink
[TASK] Add v13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ayacoo committed May 30, 2024
1 parent 412cbaf commit 535bece
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 45 deletions.
38 changes: 12 additions & 26 deletions Tests/Unit/Helper/SoundcloudHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Ayacoo\AyacooSoundcloud\Tests\Unit\Helper;

use Ayacoo\AyacooSoundcloud\Helper\SoundcloudHelper;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\AbstractOEmbedHelper;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -22,18 +24,14 @@ protected function setUp(): void
$this->subject = new SoundcloudHelper('soundcloud');
}

/**
* @test
*/
#[Test]
public function isAbstractOEmbedHelper(): void
{
self::assertInstanceOf(AbstractOEmbedHelper::class, $this->subject);
}

/**
* @test
* @dataProvider handleSoundcloudTitleDataProvider
*/
#[Test]
#[DataProvider('handleSoundcloudTitleDataProvider')]
public function handleSoundcloudTitleReturnsFilteredTitle(string $input, string $expected)
{
$params = [$input];
Expand Down Expand Up @@ -66,9 +64,7 @@ public static function handleSoundcloudTitleDataProvider(): array
];
}

/**
* @test
*/
#[Test]
public function getOEmbedUrlWithJsonFormat(): void
{
$mediaId = 'user/song';
Expand All @@ -81,9 +77,7 @@ public function getOEmbedUrlWithJsonFormat(): void
self::assertEquals($expectedUrl, $actualUrl);
}

/**
* @test
*/
#[Test]
public function getOEmbedUrlWithXmlFormat(): void
{
$mediaId = 'user/another-song';
Expand All @@ -97,10 +91,8 @@ public function getOEmbedUrlWithXmlFormat(): void
self::assertEquals($expectedUrl, $actualUrl);
}

/**
* @test
* @dataProvider getAudioIdDataProvider
*/
#[Test]
#[DataProvider('getAudioIdDataProvider')]
public function getAudioIdWithValidUrlReturnsAudioIdOrNull(string $url, mixed $expectedAudioId)
{
$params = [$url];
Expand All @@ -122,9 +114,7 @@ public static function getAudioIdDataProvider(): array
];
}

/**
* @test
*/
#[Test]
public function getOEmbedDataWithEmbedDataReturnsOptimizedArray()
{
$fileResourceMock = $this->createMock(File::class);
Expand Down Expand Up @@ -166,9 +156,7 @@ public function getOEmbedDataWithEmbedDataReturnsOptimizedArray()
self::assertSame($expected, $result);
}

/**
* @test
*/
#[Test]
public function getOEmbedDataWithoutEmbedDataReturnsEmptyArray()
{
$fileResourceMock = $this->createMock(File::class);
Expand All @@ -190,9 +178,7 @@ public function getOEmbedDataWithoutEmbedDataReturnsEmptyArray()
self::assertSame([], $result);
}

/**
* @test
*/
#[Test]
public function getPublicUrlReturnsPublicUrl()
{
$fileResourceMock = $this->createMock(File::class);
Expand Down
28 changes: 9 additions & 19 deletions Tests/Unit/Rendering/SoundcloudRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Ayacoo\AyacooSoundcloud\Event\ModifySoundcloudOutputEvent;
use Ayacoo\AyacooSoundcloud\Helper\SoundcloudHelper;
use Ayacoo\AyacooSoundcloud\Rendering\SoundcloudRenderer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\Rendering\FileRendererInterface;
Expand Down Expand Up @@ -34,17 +36,13 @@ protected function setUp(): void
$this->subject = new SoundcloudRenderer($eventDispatcherMock, $configurationManagerMock);
}

/**
* @test
*/
#[Test]
public function hasFileRendererInterface(): void
{
self::assertInstanceOf(FileRendererInterface::class, $this->subject);
}

/**
* @test
*/
#[Test]
public function canRenderWithMatchingMimeTypeReturnsTrue(): void
{
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers']['soundcloud'] = SoundcloudHelper::class;
Expand All @@ -57,9 +55,7 @@ public function canRenderWithMatchingMimeTypeReturnsTrue(): void
self::assertTrue($result);
}

/**
* @test
*/
#[Test]
public function canRenderWithMatchingMimeTypeReturnsFalse(): void
{
$fileResourceMock = $this->createMock(File::class);
Expand All @@ -70,10 +66,8 @@ public function canRenderWithMatchingMimeTypeReturnsFalse(): void
self::assertFalse($result);
}

/**
* @test
* @dataProvider getPrivacySettingWithExistingConfigReturnsBooleanDataProvider
*/
#[Test]
#[DataProvider('getPrivacySettingWithExistingConfigReturnsBooleanDataProvider')]
public function getPrivacySettingWithExistingConfigReturnsBoolean(array $pluginConfig, bool $expected)
{
$eventDispatcherMock = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
Expand Down Expand Up @@ -132,9 +126,7 @@ public static function getPrivacySettingWithExistingConfigReturnsBooleanDataProv
];
}

/**
* @test
*/
#[Test]
public function renderReturnsSoundcloudHtml(): void
{
$iframe = '<iframe src="https://www.soundcloud.com" />';
Expand Down Expand Up @@ -162,9 +154,7 @@ public function renderReturnsSoundcloudHtml(): void
self::assertSame($expected, $result);
}

/**
* @test
*/
#[Test]
public function renderWithPrivacyTrueReturnsModifiedSoundcloudHtml(): void
{
$iframe = '<iframe src="https://www.soundcloud.com" />';
Expand Down

0 comments on commit 535bece

Please sign in to comment.