Skip to content

Commit

Permalink
[TASK] Improve tests for v13 LTS & PHPUnit v11
Browse files Browse the repository at this point in the history
  • Loading branch information
twoldanski committed Oct 16, 2024
1 parent 4bdc38a commit b2332c0
Show file tree
Hide file tree
Showing 56 changed files with 305 additions and 877 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

abstract class BaseTest extends FunctionalTestCase
abstract class BaseHeadlessTesting extends FunctionalTestCase
{
protected array $coreExtensionsToLoad = [
'install',
Expand All @@ -34,7 +34,7 @@ public function setUp(): void
{
parent::setUp();

$this->importDataSet(__DIR__ . '/Fixtures/pages.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv');

$this->setUpFrontendRootPage(
1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace FriendsOfTYPO3\Headless\Tests\Functional\ContentTypes;

use FriendsOfTYPO3\Headless\Tests\Functional\BaseTest;
use FriendsOfTYPO3\Headless\Tests\Functional\BaseHeadlessTesting;

class BaseContentTypeTest extends BaseTest
abstract class BaseContentTypeTesting extends BaseHeadlessTesting
{
/**
* set up objects
Expand All @@ -22,7 +22,7 @@ public function setUp(): void
{
parent::setUp();

$this->importDataSet(__DIR__ . '/../Fixtures/content.xml');
$this->importCSVDataSet(__DIR__ . '/../Fixtures/content.csv');
}

protected function checkDefaultContentFields($contentElement, $id, $pid, $type, $colPos = 0, $categories = '')
Expand Down Expand Up @@ -54,12 +54,12 @@ protected function checkHeaderFields($contentElement, $header = '', $subheader =
self::assertTrue(isset($contentElementContent['headerLink']), 'headerLink not set');
}

protected function checkHeaderFieldsLink($contentElement, $linkText, $urlPrefix, $target)
protected function checkHeaderFieldsLink($contentElement, $link, $urlPrefix, $target)
{
$contentElementHeaderFieldsLink = $contentElement['content']['headerLink'];

self::assertIsArray($contentElementHeaderFieldsLink, 'headerLink not an array');
self::assertEquals($linkText, $contentElementHeaderFieldsLink['linkText'], 'linkText mismatch');
self::assertEquals($link, $contentElementHeaderFieldsLink['linkText'], 'linkText mismatch');
self::assertStringStartsWith($urlPrefix, $contentElementHeaderFieldsLink['href'], 'url mismatch');
self::assertEquals($target, $contentElementHeaderFieldsLink['target'], 'target mismatch');
}
Expand Down Expand Up @@ -90,7 +90,7 @@ protected function checkGalleryContentFields($contentElement)
self::assertIsArray($contentElement['content']['gallery']['rows'][1]['columns'], 'rows.columns not set');
self::assertCount(1, $contentElement['content']['gallery']['rows'][1]['columns'], 'rows.columns count mismatch');

$this->checkGalleryFile($contentElement['content']['gallery']['rows'][1]['columns'][1], '/typo3conf/ext/headless/ext_icon.gif', 'image/gif', 'MetadataTitle', 18, 16, null);
$this->checkGalleryFile($contentElement['content']['gallery']['rows'][1]['columns'][1], 'typo3conf/ext/headless/ext_icon.gif', 'image/gif', 'MetadataTitle', 18, 16, null);
}

protected function checkGalleryFile($fileElement, $originalUrl, $mimeType, $title, $width, $height, $autoplay)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/BasicListElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class BasicListElementTest extends BaseContentTypeTest
class BasicListElementTest extends BaseContentTypeTesting
{
public function testBasicListContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/BulletsElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class BulletsElementTest extends BaseContentTypeTest
class BulletsElementTest extends BaseContentTypeTesting
{
public function testBulletsContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/DefaultContentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class DefaultContentsTest extends BaseContentTypeTest
class DefaultContentsTest extends BaseContentTypeTesting
{
public function testContentStructure()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/DivElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class DivElementTest extends BaseContentTypeTest
class DivElementTest extends BaseContentTypeTesting
{
public function testDivContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/HeaderElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class HeaderElementTest extends BaseContentTypeTest
class HeaderElementTest extends BaseContentTypeTesting
{
public function testHeaderContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/HtmlElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class HtmlElementTest extends BaseContentTypeTest
class HtmlElementTest extends BaseContentTypeTesting
{
public function testHtmlContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/ImageElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class ImageElementTest extends BaseContentTypeTest
class ImageElementTest extends BaseContentTypeTesting
{
public function testImageContentElement()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuAbstractPagesElementTest extends BaseContentTypeTest
class MenuAbstractPagesElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuCategorizedContentElementTest extends BaseContentTypeTest
class MenuCategorizedContentElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuCategorizedPagesElementTest extends BaseContentTypeTest
class MenuCategorizedPagesElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/MenuPagesElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuPagesElementTest extends BaseContentTypeTest
class MenuPagesElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuRecentlyUpdatedPagesElementTest extends BaseContentTypeTest
class MenuRecentlyUpdatedPagesElementTest extends BaseContentTypeTesting
{
public function setUp(): void
{
Expand All @@ -26,9 +26,17 @@ public function setUp(): void
$modifiedSevenDayAgo = (clone $currentDate)->modify('-7 day');
$modifiedEightDayAgo = (clone $currentDate)->modify('-8 day');
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
$connection->prepare('update pages set SYS_LASTCHANGED = ? WHERE uid = 2')->execute([$modifiedOneDayAgo->getTimestamp()]);
$connection->prepare('update pages set SYS_LASTCHANGED = ? WHERE uid = 3')->execute([$modifiedSevenDayAgo->getTimestamp()]);
$connection->prepare('update pages set SYS_LASTCHANGED = ? WHERE uid = 4')->execute([$modifiedEightDayAgo->getTimestamp()]);
$sql = $connection->prepare('update pages set SYS_LASTCHANGED = :change WHERE uid = 2');
$sql->bindValue(':change', $modifiedOneDayAgo->getTimestamp());
$sql->executeStatement();

$sql = $connection->prepare('update pages set SYS_LASTCHANGED = :change WHERE uid = 3');
$sql->bindValue(':change', $modifiedSevenDayAgo->getTimestamp());
$sql->executeStatement();

$sql = $connection->prepare('update pages set SYS_LASTCHANGED = :change WHERE uid = 4');
$sql->bindValue(':change', $modifiedEightDayAgo->getTimestamp());
$sql->executeStatement();
}

public function testMenuContentElement()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuRelatedPagesElementTest extends BaseContentTypeTest
class MenuRelatedPagesElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/MenuSectionElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuSectionElementTest extends BaseContentTypeTest
class MenuSectionElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/MenuSitemapElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuSitemapElementTest extends BaseContentTypeTest
class MenuSitemapElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuSitemapSelectedPagesElementTest extends BaseContentTypeTest
class MenuSitemapSelectedPagesElementTest extends BaseContentTypeTesting
{
public function testMenuContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/MenuSubpagesElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class MenuSubpagesElementTest extends BaseContentTypeTest
class MenuSubpagesElementTest extends BaseContentTypeTesting
{
public function testMenuSubpagesContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/ShortcutElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class ShortcutElementTest extends BaseContentTypeTest
class ShortcutElementTest extends BaseContentTypeTesting
{
public function testShortcutContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/TableElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class TableElementTest extends BaseContentTypeTest
class TableElementTest extends BaseContentTypeTesting
{
public function testTableContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/TextElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class TextElementTest extends BaseContentTypeTest
class TextElementTest extends BaseContentTypeTesting
{
public function testTextContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/TextMediaElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class TextMediaElementTest extends BaseContentTypeTest
class TextMediaElementTest extends BaseContentTypeTesting
{
public function testTextMediaContentElement()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ContentTypes/TextpicElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;

class TextpicElementTest extends BaseContentTypeTest
class TextpicElementTest extends BaseContentTypeTesting
{
public function testTextpicContentElement()
{
Expand Down
55 changes: 55 additions & 0 deletions Tests/Functional/Fixtures/content.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
tt_content,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,uid,pid,sorting,colPos,CType,space_before_class,space_after_class,frame_class,layout,categories,header,subheader,header_layout,header_position,header_link,bodytext,list_type,table_caption,table_delimiter,table_enclosure,table_class,table_tfoot,table_header_position,cols,bullets_type,records,image,assets,pages,selected_categories,category_field
,1,1,1,0,text,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999","
<p><a href=""t3://page?uid=2 _blank LinkClass LinkTitle parameter=999"">Link</a></p>
",,,,,,,,,,,,,,,
,3,1,2,0,header,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999",,,,,,,,,,,,,,,,
,4,1,3,0,html,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999","<a href=""t3://page?uid=2 _blank LinkClass LinkTitle parameter=999"">Link</a>",,,,,,,,,,,,,,,
,5,1,4,0,div,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999","<a href=""t3://page?uid=2 _blank LinkClass LinkTitle parameter=999"">Link</a>",,,,,,,,,,,,,,,
,6,1,5,0,list,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999","<a href=""t3://page?uid=2 _blank LinkClass LinkTitle parameter=999"">Link</a>",BasicList,,,,,,,,,,,,,,
,7,1,6,0,table,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999","""Cell1.1"";""Cell1.2"";""Cell1.3"";""Cell1.4""
""Cell2.1"";"""";"""";""""
""Cell3.1"";"""";"""";""""
"""""""";"""";"""";""""",,TableCaption,59,34,striped,1,1,6,,,,,,,
,8,1,7,0,bullets,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999","Top1
Top2
Top3",,,,,,,,,1,,,,,,
,9,1,8,0,shortcut,SpaceBefore,SpaceAfter,Frame,1,1,Header,SubHeader,1,2,"t3://page?uid=2 _blank LinkClass LinkTitle parameter=999",,,,,,,,,,,"pages_1,tt_content_2,tt_content_1",,,,,
,2,1,1,1,textmedia,,,default,,,,,,,,"<a href=""t3://page?uid=2 _blank LinkClass LinkTitle parameter=999"">Link</a>",,,,,,,,,,,1,,,,
,10,1,1,1,image,,,default,,,,,,,,,,,,,,,,,,,,1,,,
,11,1,1,1,textpic,,,default,,,,,,,,"<a href=""t3://page?uid=2 _blank LinkClass LinkTitle parameter=999"">Link</a>",,,,,,,,,,,1,,,,
,12,1,1,1,menu_subpages,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,,,
,13,1,1,1,menu_sitemap,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,"1,2,3",,
,14,1,1,1,menu_pages,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,"1,2,3,4",,
,15,1,1,1,menu_section,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,"1,4",,
,16,1,1,1,menu_recently_updated,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,1,,
,17,1,1,1,header,,,default,,3,,,,,,,,,,,,,,,,,,,,,
,18,1,1,1,textpic,,,default,,3,,,,,,,,,,,,,,,,,,,,,
,19,1,1,1,menu_categorized_content,SpaceBefore,SpaceAfter,default,,3,Header,SubHeader,0,2,,,,,,,,,,,,,,,,3,categories
,20,2,1,1,menu_categorized_pages,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,,3,categories
,21,5,1,1,menu_sitemap_pages,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,5,,
,22,1,1,1,menu_related_pages,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,,,
,23,1,1,1,menu_abstract,SpaceBefore,SpaceAfter,default,,1,Header,SubHeader,0,2,,,,,,,,,,,,,,,5,,
sys_category,,,
,uid,pid,title
,1,0,SysCategory1Title
,2,0,SysCategory2Title
,3,0,SysCategory3Title
sys_category_record_mm,,,,,,
,tablenames,uid_foreign,uid_local,fieldname,sorting,sorting_foreign
,tt_content,1,1,categories,,
,tt_content,1,2,categories,,
,pages,5,3,categories,,
,tt_content,17,3,categories,1,0
,tt_content,18,3,categories,1,0
sys_file,,,,,,,,,,,,,,
,uid,pid,storage,type,identifier,identifier_hash,folder_hash,extension,mime_type,name,sha1,size,creation_date,modification_date
,1,0,0,1,/typo3conf/ext/headless/ext_icon.gif,ae03df120da87352822f4aae6d476086cb8c0cf8,85051482e1ba204348a9b9f6c1a37069e77de027,gif,image/gif,ext_icon.gif,4a53ba5b5a156b82e3efd443f9a402f8c6e6dd08,177,1400176659,1400176659
sys_file_metadata,,,,,,
,uid,pid,file,title,width,height
,1,0,1,MetadataTitle,18,16
sys_file_reference,,,,,,,
,uid,pid,uid_local,uid_foreign,tablenames,fieldname,autoplay
,1,1,1,2,tt_content,assets,1
,2,1,1,10,tt_content,image,1
,3,1,1,11,tt_content,image,1
Loading

0 comments on commit b2332c0

Please sign in to comment.