Skip to content

Commit

Permalink
[TASK] Add TYPO3 v13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ayacoo committed May 30, 2024
1 parent d4afb4b commit 63681ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 41 deletions.
26 changes: 7 additions & 19 deletions Tests/Unit/Helper/TiktokHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Ayacoo\Tiktok\Tests\Unit\Helper;

use Ayacoo\Tiktok\Helper\TiktokHelper;
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,17 +23,12 @@ protected function setUp(): void
$this->subject = new TiktokHelper('tiktok');
}

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

/**
* @test
*/
#[Test]
public function getOEmbedUrlReturnsUrl()
{
$mediaId = '123456';
Expand All @@ -45,9 +41,7 @@ public function getOEmbedUrlReturnsUrl()
self::assertEquals($expectedUrl, $result);
}

/**
* @test
*/
#[Test]
public function getPublicUrlReturnsPublicUrl()
{
$properties = ['tiktok_username' => 'username123'];
Expand All @@ -70,9 +64,7 @@ public function getPublicUrlReturnsPublicUrl()
self::assertEquals($expectedUrl, $result);
}

/**
* @test
*/
#[Test]
public function getMetaData()
{
$fileMock = $this->getMockBuilder(File::class)
Expand Down Expand Up @@ -112,9 +104,7 @@ public function getMetaData()
self::assertEquals($expectedMetaData, $result);
}

/**
* @test
*/
#[Test]
public function handleTiktokTitle()
{
$title = 'Test <span>Title</span>';
Expand All @@ -127,9 +117,7 @@ public function handleTiktokTitle()
self::assertEquals($expectedTitle, $result);
}

/**
* @test
*/
#[Test]
public function handleTiktokTitleWithEmojis()
{
$title = 'Test <span>Title 😊</span>';
Expand Down
28 changes: 9 additions & 19 deletions Tests/Unit/Rendering/TiktokRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Ayacoo\Tiktok\Event\ModifyTiktokOutputEvent;
use Ayacoo\Tiktok\Helper\TiktokHelper;
use Ayacoo\Tiktok\Rendering\TiktokRenderer;
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 TiktokRenderer($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']['tiktok'] = TiktokHelper::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 renderReturnsTiktokHtml(): void
{
$iframe = '<iframe src="https://www.tiktok.com" />';
Expand Down Expand Up @@ -162,9 +154,7 @@ public function renderReturnsTiktokHtml(): void
self::assertSame($expected, $result);
}

/**
* @test
*/
#[Test]
public function renderWithPrivacyTrueReturnsModifiedTiktokHtml(): void
{
$iframe = '<iframe src="https://www.tiktok.com" />';
Expand Down
3 changes: 0 additions & 3 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@

$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'][$mediaFileExt] = 'video/' . $mediaFileExt;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext'] .= ',' . $mediaFileExt;

$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
$iconRegistry->registerFileExtension('tiktok', 'mimetypes-media-image-' . $mediaFileExt);
})('tiktok');

0 comments on commit 63681ca

Please sign in to comment.