Skip to content
Snippets Groups Projects
Commit 62ba7405 authored by Helmut Hummel's avatar Helmut Hummel Committed by Wouter Wolters
Browse files

[TASK] Add a few additional tests for PageRepository

Resolves: #76150
Releases: master
Change-Id: Ia51ec33ba4aacabc884292d4a9508ce0d2c4cd9d
Reviewed-on: https://review.typo3.org/48078


Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
parent 3d82d52a
Branches
Tags
No related merge requests found
...@@ -261,6 +261,46 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ...@@ -261,6 +261,46 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
$this->pageSelectObject->getPage(1); $this->pageSelectObject->getPage(1);
} }
/**
* @test
*/
public function getWorkspaceVersionReturnsTheCorrectMethod()
{
// initialization
$wsid = 987654321;
$GLOBALS['TCA'] = array(
'pages' => $this->defaultTcaForPages
);
$GLOBALS['SIM_ACCESS_TIME'] = 123;
// simulate calls from \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->fetch_the_id()
$this->pageSelectObject->versioningPreview = true;
$this->pageSelectObject->versioningWorkspaceId = $wsid;
$this->pageSelectObject->init(false);
$GLOBALS['TYPO3_DB']->expects($this->at(0))
->method('exec_SELECTgetSingleRow')
->with(
'*',
'pages',
$this->logicalAnd(
$this->stringContains('pid=-1 AND'),
$this->stringContains('t3ver_oid=1 AND'),
$this->stringContains('t3ver_wsid=' . $wsid . ' AND pages.deleted=0')
)
)->willReturn(array('uid' => 1));
$GLOBALS['TYPO3_DB']->expects($this->at(1))
->method('exec_SELECTgetSingleRow')
->with(
'uid',
'pages',
$this->logicalAnd(
$this->stringContains('t3ver_wsid=' . $wsid . ' AND pages.deleted=0 AND pages.hidden=0 AND pages.starttime<=123 AND (pages.endtime=0 OR pages.endtime>123) AND 1=1')
)
);
$this->pageSelectObject->getWorkspaceVersionOfRecord($wsid, 'pages', 1);
}
//////////////////////////////// ////////////////////////////////
// Tests concerning versioning // Tests concerning versioning
//////////////////////////////// ////////////////////////////////
...@@ -337,6 +377,39 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase ...@@ -337,6 +377,39 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
$this->assertThat($conditions, $this->stringContains(' AND (' . $table . '.t3ver_wsid=0 OR ' . $table . '.t3ver_wsid=2)'), 'No versioning placeholders'); $this->assertThat($conditions, $this->stringContains(' AND (' . $table . '.t3ver_wsid=0 OR ' . $table . '.t3ver_wsid=2)'), 'No versioning placeholders');
} }
/**
* @test
*/
public function initSetsPublicPropertyCorrectlyForWorkspacePreview()
{
$GLOBALS['TCA'] = array(
'pages' => $this->defaultTcaForPages,
);
$this->pageSelectObject->versioningPreview = true;
$this->pageSelectObject->versioningWorkspaceId = 2;
$this->pageSelectObject->init(false);
$this->assertSame(' AND pages.deleted=0 AND (pages.t3ver_wsid=0 OR pages.t3ver_wsid=2)', $this->pageSelectObject->where_hid_del);
}
/**
* @test
*/
public function initSetsPublicPropertyCorrectlyForLive()
{
$GLOBALS['TCA'] = array(
'pages' => $this->defaultTcaForPages,
);
$GLOBALS['SIM_ACCESS_TIME'] = 123;
$this->pageSelectObject->versioningPreview = false;
$this->pageSelectObject->versioningWorkspaceId = 0;
$this->pageSelectObject->init(false);
$this->assertSame(' AND pages.deleted=0 AND pages.t3ver_state<=0 AND pages.hidden=0 AND pages.starttime<=123 AND (pages.endtime=0 OR pages.endtime>123)', $this->pageSelectObject->where_hid_del);
}
/** /**
* @test * @test
*/ */
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment