-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
165 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd" | ||
backupGlobals="true" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" | ||
cacheResult="false" | ||
colors="true" | ||
convertDeprecationsToExceptions="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
forceCoversAnnotation="false" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
stopOnIncomplete="false" | ||
stopOnSkipped="false" | ||
verbose="false" | ||
> | ||
<coverage/> | ||
<testsuites> | ||
<testsuite name="Unit tests"> | ||
<!-- | ||
This path either needs an adaption in extensions, or an extension's | ||
test location path needs to be given to phpunit. | ||
--> | ||
<directory suffix="Test.php">./</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<!-- @deprecated: will be removed with next major version, constant TYPO3_MODE is deprecated --> | ||
<const name="TYPO3_MODE" value="BE"/> | ||
<ini name="display_errors" value="1"/> | ||
<env name="TYPO3_CONTEXT" value="Testing"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ayacoo\AyacooSoundcloud\Tests\Unit\Domain\Model; | ||
|
||
use Ayacoo\AyacooSoundcloud\Helper\SoundcloudHelper; | ||
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\AbstractOEmbedHelper; | ||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase; | ||
|
||
final class SoundcloudHelperTest extends UnitTestCase | ||
{ | ||
private SoundcloudHelper $subject; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->subject = new SoundcloudHelper('soundcloud'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function isAbstractEntity(): void | ||
{ | ||
self::assertInstanceOf(AbstractOEmbedHelper::class, $this->subject); | ||
} | ||
|
||
/** | ||
* @test | ||
* @dataProvider handleSoundcloudTitleDataProvider | ||
*/ | ||
public function handleSoundcloudTitleReturnsFilteredTitle(string $input, string $expected) | ||
{ | ||
$params = [$input]; | ||
$methodName = 'handleSoundcloudTitle'; | ||
$result = $this->buildReflectionForProtectedFunction($methodName, $params); | ||
|
||
self::assertEquals($expected, $result); | ||
} | ||
|
||
public function handleSoundcloudTitleDataProvider(): array | ||
{ | ||
return [ | ||
'No filter needed' => [ | ||
'Test', | ||
'Test' | ||
], | ||
'Strip Tags' => [ | ||
'<h1>Test</h1>', | ||
'Test' | ||
], | ||
'Trim' => [ | ||
'Test ', | ||
'Test' | ||
], | ||
'MaxLength' => [ | ||
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', | ||
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata' | ||
], | ||
]; | ||
} | ||
|
||
private function buildReflectionForProtectedFunction(string $methodName, array $params) | ||
{ | ||
$reflectionCalendar = new \ReflectionClass($this->subject); | ||
$method = $reflectionCalendar->getMethod($methodName); | ||
$method->setAccessible(true); | ||
return $method->invokeArgs($this->subject, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters