Setup unit testing

* Add dependency.
* Remove empty tearDown() methods.
* Fix signature of setUp() to be compatible with recent phpunit.
* Temporary fix syntax issues in test files

Relates: #8092
This commit is contained in:
Daniel Siepmann 2021-01-07 09:01:58 +01:00
parent 0c58be43ff
commit cb50981a2b
9 changed files with 29 additions and 67 deletions

View file

@ -14,7 +14,7 @@ class DateControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder(\Wrm\Events\Controller\DateController::class)
@ -23,11 +23,6 @@ class DateControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
->getMock();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/
@ -38,10 +33,10 @@ class DateControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
->disableOriginalConstructor()
->getMock();
$dateRepository = $this->getMockBuilder(\::class)
->setMethods(['findAll'])
->disableOriginalConstructor()
->getMock();
// $dateRepository = $this->getMockBuilder(\::class)
// ->setMethods(['findAll'])
// ->disableOriginalConstructor()
// ->getMock();
$dateRepository->expects(self::once())->method('findAll')->will(self::returnValue($allDates));
$this->inject($this->subject, 'dateRepository', $dateRepository);

View file

@ -14,7 +14,7 @@ class EventControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder(\Wrm\Events\Controller\EventController::class)
@ -23,11 +23,6 @@ class EventControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
->getMock();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/
@ -38,10 +33,10 @@ class EventControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
->disableOriginalConstructor()
->getMock();
$eventRepository = $this->getMockBuilder(\::class)
->setMethods(['findAll'])
->disableOriginalConstructor()
->getMock();
// $eventRepository = $this->getMockBuilder(\::class)
// ->setMethods(['findAll'])
// ->disableOriginalConstructor()
// ->getMock();
$eventRepository->expects(self::once())->method('findAll')->will(self::returnValue($allEvents));
$this->inject($this->subject, 'eventRepository', $eventRepository);

View file

@ -14,7 +14,7 @@ class EventsControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder(\Wrm\Events\Controller\EventsController::class)
@ -23,11 +23,6 @@ class EventsControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
->getMock();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/
@ -38,10 +33,10 @@ class EventsControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
->disableOriginalConstructor()
->getMock();
$eventsRepository = $this->getMockBuilder(\::class)
->setMethods(['findAll'])
->disableOriginalConstructor()
->getMock();
// $eventsRepository = $this->getMockBuilder(\::class)
// ->setMethods(['findAll'])
// ->disableOriginalConstructor()
// ->getMock();
$eventsRepository->expects(self::once())->method('findAll')->will(self::returnValue($allEventss));
$this->inject($this->subject, 'eventsRepository', $eventsRepository);

View file

@ -14,17 +14,12 @@ class DateTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = new \Wrm\Events\Domain\Model\Date();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/

View file

@ -14,17 +14,12 @@ class EventTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = new \Wrm\Events\Domain\Model\Event();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/

View file

@ -14,17 +14,12 @@ class EventsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = new \Wrm\Events\Domain\Model\Events();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/
@ -507,7 +502,7 @@ class EventsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
public function setDateForObjectStorageContainingSetsDate()
{
$date = new ();
// $date = new ();
$objectStorageHoldingExactlyOneDate = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$objectStorageHoldingExactlyOneDate->attach($date);
$this->subject->setDate($objectStorageHoldingExactlyOneDate);
@ -524,7 +519,7 @@ class EventsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
public function addDateToObjectStorageHoldingDate()
{
$date = new ();
// $date = new ();
$dateObjectStorageMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
->setMethods(['attach'])
->disableOriginalConstructor()
@ -541,7 +536,7 @@ class EventsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
public function removeDateFromObjectStorageHoldingDate()
{
$date = new ();
// $date = new ();
$dateObjectStorageMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
->setMethods(['detach'])
->disableOriginalConstructor()
@ -570,7 +565,7 @@ class EventsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
public function setRegionForObjectStorageContainingSetsRegion()
{
$region = new ();
// $region = new ();
$objectStorageHoldingExactlyOneRegion = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$objectStorageHoldingExactlyOneRegion->attach($region);
$this->subject->setRegion($objectStorageHoldingExactlyOneRegion);
@ -587,7 +582,7 @@ class EventsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
public function addRegionToObjectStorageHoldingRegion()
{
$region = new ();
// $region = new ();
$regionObjectStorageMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
->setMethods(['attach'])
->disableOriginalConstructor()
@ -604,7 +599,7 @@ class EventsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
public function removeRegionFromObjectStorageHoldingRegion()
{
$region = new ();
// $region = new ();
$regionObjectStorageMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
->setMethods(['detach'])
->disableOriginalConstructor()

View file

@ -14,17 +14,12 @@ class OrganizerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = new \Wrm\Events\Domain\Model\Organizer();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/

View file

@ -14,17 +14,12 @@ class RegionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected $subject = null;
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = new \Wrm\Events\Domain\Model\Region();
}
protected function tearDown()
{
parent::tearDown();
}
/**
* @test
*/

View file

@ -29,6 +29,8 @@
}
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5"
"squizlabs/php_codesniffer": "^3.5",
"phpunit/phpunit": "^9.0",
"typo3/testing-framework": "^6.6"
}
}