Commit 6b088050 authored by Thomas Löffler's avatar Thomas Löffler

First changes of unit tests

* Adds build task for tests
* Changes tests to namespaces
parent cb756b2e
Pipeline #3404 failed with stages
in 11 seconds
...@@ -12,10 +12,23 @@ before_script: ...@@ -12,10 +12,23 @@ before_script:
stages: stages:
- dump - dump
- test
- build - build
- layout - layout
- deploy - deploy
test:
stage: test
image: php:7.0-alpine
before_script:
- export TYPO3_PATH_WEB="$PWD/.Build/Web"
- export COMPOSER_CACHE_DIR=.cache/composer
- php -r "copy('https://getcomposer.org/composer.phar', 'composer.phar');"
- php composer.phar install
script:
- bin/phpunit -c .gitlab-ci/Tests/UnitTests.xml
build: build:
stage: build stage: build
image: php:7.0-alpine image: php:7.0-alpine
......
<phpunit
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="../../vendor/nimut/testing-framework/src/TestingFramework/Bootstrap/UnitTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
>
<testsuites>
<testsuite name="ter_fe2 tests">
<directory>../../html/typo3conf/ext/ter_fe2/Tests/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
<?php <?php
namespace T3o\TerFe2\Tests\Unit\Domain\Model;
/******************************************************************* /*******************************************************************
* Copyright notice * Copyright notice
* *
...@@ -26,17 +28,17 @@ ...@@ -26,17 +28,17 @@
/** /**
* Tests for the Extension Model * Tests for the Extension Model
*/ */
class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase class ExtensionTest extends \Nimut\TestingFramework\TestCase\UnitTestCase
{ {
/** /**
* @var Tx_TerFe2_Domain_Model_Extension * @var \T3o\TerFe2\Domain\Model\Extension
*/ */
protected $fixture; protected $fixture;
public function setUp() public function setUp()
{ {
$this->fixture = new Tx_TerFe2_Domain_Model_Extension(); $this->fixture = new \T3o\TerFe2\Domain\Model\Extension();
$this->addVersionsToExtension($this->fixture); $this->addVersionsToExtension($this->fixture);
} }
...@@ -45,10 +47,16 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase ...@@ -45,10 +47,16 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase
unset($this->fixture); unset($this->fixture);
} }
protected function addVersionsToExtension($extension, $amount = 4) /**
* @test
* @param \T3o\TerFe2\Domain\Model\Extension $extension
* @param int $amount
* @return void
*/
public function addVersionsToExtension(\T3o\TerFe2\Domain\Model\Extension $extension, $amount = 4)
{ {
for ($index = 1; $index <= $amount; $index++) { for ($index = 1; $index <= $amount; $index++) {
$version = new Tx_TerFe2_Domain_Model_Version(); $version = new \T3o\TerFe2\Domain\Model\Version();
$version->setExtension($this->fixture); $version->setExtension($this->fixture);
$version->setVersionNumber($index); $version->setVersionNumber($index);
$version->setVersionString('0.0.' . (string)$index); $version->setVersionString('0.0.' . (string)$index);
...@@ -92,7 +100,7 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase ...@@ -92,7 +100,7 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase
*/ */
public function tryingToRemoveAVersionWhichDoesNotBelongToTheExtensionThrowsException() public function tryingToRemoveAVersionWhichDoesNotBelongToTheExtensionThrowsException()
{ {
$version = new Tx_TerFe2_Domain_Model_Version(); $version = new \T3o\TerFe2\Domain\Model\Version();
$this->fixture->removeVersion($version); $this->fixture->removeVersion($version);
} }
...@@ -101,7 +109,7 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase ...@@ -101,7 +109,7 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase
*/ */
public function removingTheLastVersionSetsLastVersionToNull() public function removingTheLastVersionSetsLastVersionToNull()
{ {
$extension = new Tx_TerFe2_Domain_Model_Extension(); $extension = new \T3o\TerFe2\Domain\Model\Extension();
$this->addVersionsToExtension($extension, 1); $this->addVersionsToExtension($extension, 1);
$extension->removeVersion($extension->getLastVersion()); $extension->removeVersion($extension->getLastVersion());
......
<?php <?php
namespace T3o\TerFe2\Tests\Unit\Task;
/******************************************************************* /*******************************************************************
* Copyright notice * Copyright notice
...@@ -24,11 +25,17 @@ ...@@ -24,11 +25,17 @@
* *
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/ ******************************************************************/
class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_testcase
/**
* Class CheckForOutdatedExtensionsTest
*
* @author Thomas Löffler <loeffler@spooner-web.de>
*/
class CheckForOutdatedExtensionsTest extends \Nimut\TestingFramework\TestCase\UnitTestCase
{ {
/** /**
* @var Tx_TerFe2_Task_CheckForOutdatedExtensions * @var \T3o\TerFe2\Task\CheckForOutdatedExtensions
*/ */
protected $subject = null; protected $subject = null;
...@@ -56,7 +63,7 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test ...@@ -56,7 +63,7 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
public function setUp() public function setUp()
{ {
$this->subject = $this->getAccessibleMock( $this->subject = $this->getAccessibleMock(
'Tx_TerFe2_Task_CheckForOutdatedExtensions', \T3o\TerFe2\Task\CheckForOutdatedExtensions::class,
array('dummy') array('dummy')
); );
} }
...@@ -68,14 +75,14 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test ...@@ -68,14 +75,14 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
public function subjectExists() public function subjectExists()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Tx_TerFe2_Task_CheckForOutdatedExtensions', \T3o\TerFe2\Task\CheckForOutdatedExtensions::class,
$this->subject $this->subject
); );
} }
/** /**
* @test * @test
* @param Tx_TerFe2_Domain_Model_Relation $dependency * @param \T3o\TerFe2\Domain\Model\Relation $dependency
* @dataProvider isVersionDependingOnAnActiveSupportedTypo3VersionReturnsTrueForSupportedVersionsDataProvider * @dataProvider isVersionDependingOnAnActiveSupportedTypo3VersionReturnsTrueForSupportedVersionsDataProvider
* @return void * @return void
*/ */
...@@ -134,7 +141,7 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test ...@@ -134,7 +141,7 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
/** /**
* @test * @test
* @param Tx_TerFe2_Domain_Model_Relation $dependency * @param \T3o\TerFe2\Domain\Model\Relation $dependency
* @dataProvider isVersionDependingOnAnActiveSupportedTypo3VersionReturnsFalseForUnsupportedVersionsDataProvider * @dataProvider isVersionDependingOnAnActiveSupportedTypo3VersionReturnsFalseForUnsupportedVersionsDataProvider
* @return void * @return void
*/ */
...@@ -168,11 +175,11 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test ...@@ -168,11 +175,11 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
* @param string $minVersion * @param string $minVersion
* @param string $maxVersion * @param string $maxVersion
* *
* @return Tx_TerFe2_Domain_Model_Relation * @return \T3o\TerFe2\Domain\Model\Relation
*/ */
protected function buildRelation($minVersion, $maxVersion) protected function buildRelation($minVersion, $maxVersion)
{ {
$relation = new Tx_TerFe2_Domain_Model_Relation(); $relation = new \T3o\TerFe2\Domain\Model\Relation();
$relation->setMinimumVersion(\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($minVersion)); $relation->setMinimumVersion(\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($minVersion));
$relation->setMaximumVersion(\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($maxVersion)); $relation->setMaximumVersion(\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($maxVersion));
......
<?php <?php
namespace T3o\TerFe2\Tests\Unit\Utility;
/** /**
* This file is part of the TYPO3 CMS project. * This file is part of the TYPO3 CMS project.
* *
...@@ -13,9 +15,11 @@ ...@@ -13,9 +15,11 @@
*/ */
/** /**
* Class Tx_TerFe2_Utility_ArchiveTest * Class ArchiveUtilityTest
*
* @author Thomas Löffler <loeffler@spooner-web.de>
*/ */
class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase class ArchiveUtilityTest extends \Nimut\TestingFramework\TestCase\UnitTestCase
{ {
/** /**
...@@ -27,7 +31,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase ...@@ -27,7 +31,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
public function extractEmConfReturnsFullAndValidDataArray($code, $expected) public function extractEmConfReturnsFullAndValidDataArray($code, $expected)
{ {
$subject = $this->getAccessibleMock( $subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive', \T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy') array('dummy')
); );
$emConf = $subject->_call('extractEmConf', $code); $emConf = $subject->_call('extractEmConf', $code);
...@@ -75,7 +79,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase ...@@ -75,7 +79,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
$expected = array('bar' => 'baz'); $expected = array('bar' => 'baz');
$subject = $this->getAccessibleMock( $subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive', \T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy') array('dummy')
); );
$emConf = $subject->_call('extractEmConf', $code); $emConf = $subject->_call('extractEmConf', $code);
...@@ -92,7 +96,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase ...@@ -92,7 +96,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
$code = '<?php $EM_CONF[$_EXTKEY] = array(\'bar\' => \'baz\'); $foo = TRUE ?>'; $code = '<?php $EM_CONF[$_EXTKEY] = array(\'bar\' => \'baz\'); $foo = TRUE ?>';
$subject = $this->getAccessibleMock( $subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive', \T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy') array('dummy')
); );
$emConf = $subject->_call('extractEmConf', $code); $emConf = $subject->_call('extractEmConf', $code);
...@@ -108,7 +112,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase ...@@ -108,7 +112,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
$code = '<?php $EM_CONFOTHER[$_EXTKEY] = array(\'bar\' => \'baz\'); ?>'; $code = '<?php $EM_CONFOTHER[$_EXTKEY] = array(\'bar\' => \'baz\'); ?>';
$subject = $this->getAccessibleMock( $subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive', \T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy') array('dummy')
); );
$emConf = $subject->_call('extractEmConf', $code); $emConf = $subject->_call('extractEmConf', $code);
......
Markdown is supported
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