-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Added functional and unit test for VisibilityChecker, fixed…
… other tests to have working functional and unit tests
- Loading branch information
Showing
8 changed files
with
226 additions
and
121 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
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
64 changes: 64 additions & 0 deletions
64
Tests/Functional/Service/PageLayoutHeader/VisibilityCheckerTest.php
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,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace YoastSeoForTypo3\YoastSeo\Tests\Functional\Service\PageLayoutHeader; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use TYPO3\TestingFramework\Core\AccessibleObjectInterface; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
use YoastSeoForTypo3\YoastSeo\Service\PageLayoutHeader\VisibilityChecker; | ||
|
||
#[CoversClass(VisibilityChecker::class)] | ||
class VisibilityCheckerTest extends FunctionalTestCase | ||
{ | ||
/** | ||
* @var VisibilityChecker&MockObject&AccessibleObjectInterface | ||
*/ | ||
protected VisibilityChecker $subject; | ||
|
||
protected array $configurationToUseInTestInstance = [ | ||
'EXTCONF' => [ | ||
'yoast_seo' => [ | ||
'allowedDoktypes' => [1,6], | ||
], | ||
], | ||
]; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv'); | ||
$this->setUpBackendUser(1); | ||
} | ||
|
||
#[Test] | ||
#[DataProvider('isSnippetPreviewEnabledCorrectlyBasedOnPageDoktypeDataProvider')] | ||
public function isSnippetPreviewEnabledCorrectlyBasedOnPageDoktype(int $doktype, bool $expected): void | ||
{ | ||
$visibilityChecker = new VisibilityChecker(); | ||
self::assertEquals($expected, $visibilityChecker->shouldShowPreview(1, ['doktype' => $doktype])); | ||
} | ||
|
||
public static function isSnippetPreviewEnabledCorrectlyBasedOnPageDoktypeDataProvider(): array | ||
{ | ||
return [ | ||
'doktype 1 should return true' => [ | ||
1, | ||
true, | ||
], | ||
'doktype 6 should return true' => [ | ||
6, | ||
true, | ||
], | ||
'doktype 2 should return false' => [ | ||
2, | ||
false, | ||
], | ||
]; | ||
} | ||
} |
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
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
Oops, something went wrong.