TYPO3 CMS  TYPO3_7-6
AbstractDataHandlerActionTestCase.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
25 
30 
35 
42  protected $expectedErrorLogEntries = 0;
43 
47  protected $testExtensionsToLoad = [
48  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/irre_tutorial',
49  ];
50 
55  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/AdditionalConfiguration.php' => 'typo3conf/AdditionalConfiguration.php',
56  ];
57 
61  protected $recordIds = [];
62 
66  protected $actionService;
67 
71  protected $backendUser;
72 
73  protected function setUp()
74  {
75  parent::setUp();
76 
77  $this->backendUser = $this->setUpBackendUserFromFixture(self::VALUE_BackendUserId);
78  // By default make tests on live workspace
79  $this->backendUser->workspace = 0;
80 
81  $this->actionService = $this->getActionService();
82  \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
83  }
84 
85  protected function tearDown()
86  {
87  $this->assertErrorLogEntries();
88  unset($this->actionService);
89  unset($this->recordIds);
90  parent::tearDown();
91  }
92 
96  protected function getActionService()
97  {
99  \TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework\ActionService::class
100  );
101  }
102 
106  protected function importScenarioDataSet($dataSetName)
107  {
108  $fileName = rtrim($this->scenarioDataSetDirectory, '/') . '/' . $dataSetName . '.csv';
109  $fileName = GeneralUtility::getFileAbsFileName($fileName);
110  $this->importCSVDataSet($fileName);
111  }
112 
113  protected function assertAssertionDataSet($dataSetName)
114  {
115  $fileName = rtrim($this->assertionDataSetDirectory, '/') . '/' . $dataSetName . '.csv';
116  $fileName = GeneralUtility::getFileAbsFileName($fileName);
117  $this->assertCSVDataSet($fileName);
118  }
119 
125  protected function assertErrorLogEntries()
126  {
127  if ($this->expectedErrorLogEntries === null) {
128  return;
129  }
130  $errorLogEntries = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'sys_log', 'error IN (1,2)');
131  $actualErrorLogEntries = count($errorLogEntries);
132  if ($actualErrorLogEntries === $this->expectedErrorLogEntries) {
133  $this->assertSame($this->expectedErrorLogEntries, $actualErrorLogEntries);
134  } else {
135  $failureMessage = 'Expected ' . $this->expectedErrorLogEntries . ' entries in sys_log, but got ' . $actualErrorLogEntries . LF;
136  foreach ($errorLogEntries as $entry) {
137  $entryData = unserialize($entry['log_data']);
138  $entryMessage = vsprintf($entry['details'], $entryData);
139  $failureMessage .= '* ' . $entryMessage . LF;
140  }
141  $this->fail($failureMessage);
142  }
143  }
144 
149  {
150  return new \TYPO3\CMS\Core\Tests\Functional\Framework\Constraint\RequestSection\HasRecordConstraint();
151  }
152 
157  {
158  return new \TYPO3\CMS\Core\Tests\Functional\Framework\Constraint\RequestSection\DoesNotHaveRecordConstraint();
159  }
160 
165  {
166  return new \TYPO3\CMS\Core\Tests\Functional\Framework\Constraint\RequestSection\StructureHasRecordConstraint();
167  }
168 
173  {
174  return new \TYPO3\CMS\Core\Tests\Functional\Framework\Constraint\RequestSection\StructureDoesNotHaveRecordConstraint();
175  }
176 }
static getFileAbsFileName($filename, $onlyRelative=true, $relToTYPO3_mainDir=false)