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:
stages:
- dump
- test
- build
- layout
- 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:
stage: build
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
namespace T3o\TerFe2\Tests\Unit\Domain\Model;
/*******************************************************************
* Copyright notice
*
......@@ -26,17 +28,17 @@
/**
* 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;
public function setUp()
{
$this->fixture = new Tx_TerFe2_Domain_Model_Extension();
$this->fixture = new \T3o\TerFe2\Domain\Model\Extension();
$this->addVersionsToExtension($this->fixture);
}
......@@ -45,10 +47,16 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase
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++) {
$version = new Tx_TerFe2_Domain_Model_Version();
$version = new \T3o\TerFe2\Domain\Model\Version();
$version->setExtension($this->fixture);
$version->setVersionNumber($index);
$version->setVersionString('0.0.' . (string)$index);
......@@ -92,7 +100,7 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase
*/
public function tryingToRemoveAVersionWhichDoesNotBelongToTheExtensionThrowsException()
{
$version = new Tx_TerFe2_Domain_Model_Version();
$version = new \T3o\TerFe2\Domain\Model\Version();
$this->fixture->removeVersion($version);
}
......@@ -101,7 +109,7 @@ class Tx_TerFe2_Domain_Model_ExtensionTest extends Tx_Phpunit_TestCase
*/
public function removingTheLastVersionSetsLastVersionToNull()
{
$extension = new Tx_TerFe2_Domain_Model_Extension();
$extension = new \T3o\TerFe2\Domain\Model\Extension();
$this->addVersionsToExtension($extension, 1);
$extension->removeVersion($extension->getLastVersion());
......
<?php
namespace T3o\TerFe2\Tests\Unit\Task;
/*******************************************************************
* Copyright notice
......@@ -24,11 +25,17 @@
*
* 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;
......@@ -56,7 +63,7 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
public function setUp()
{
$this->subject = $this->getAccessibleMock(
'Tx_TerFe2_Task_CheckForOutdatedExtensions',
\T3o\TerFe2\Task\CheckForOutdatedExtensions::class,
array('dummy')
);
}
......@@ -68,14 +75,14 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
public function subjectExists()
{
$this->assertInstanceOf(
'Tx_TerFe2_Task_CheckForOutdatedExtensions',
\T3o\TerFe2\Task\CheckForOutdatedExtensions::class,
$this->subject
);
}
/**
* @test
* @param Tx_TerFe2_Domain_Model_Relation $dependency
* @param \T3o\TerFe2\Domain\Model\Relation $dependency
* @dataProvider isVersionDependingOnAnActiveSupportedTypo3VersionReturnsTrueForSupportedVersionsDataProvider
* @return void
*/
......@@ -134,7 +141,7 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
/**
* @test
* @param Tx_TerFe2_Domain_Model_Relation $dependency
* @param \T3o\TerFe2\Domain\Model\Relation $dependency
* @dataProvider isVersionDependingOnAnActiveSupportedTypo3VersionReturnsFalseForUnsupportedVersionsDataProvider
* @return void
*/
......@@ -168,11 +175,11 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
* @param string $minVersion
* @param string $maxVersion
*
* @return Tx_TerFe2_Domain_Model_Relation
* @return \T3o\TerFe2\Domain\Model\Relation
*/
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->setMaximumVersion(\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($maxVersion));
......
<?php
namespace T3o\TerFe2\Tests\Unit\Utility;
/**
* This file is part of the TYPO3 CMS project.
*
......@@ -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
public function extractEmConfReturnsFullAndValidDataArray($code, $expected)
{
$subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive',
\T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy')
);
$emConf = $subject->_call('extractEmConf', $code);
......@@ -75,7 +79,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
$expected = array('bar' => 'baz');
$subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive',
\T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy')
);
$emConf = $subject->_call('extractEmConf', $code);
......@@ -92,7 +96,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
$code = '<?php $EM_CONF[$_EXTKEY] = array(\'bar\' => \'baz\'); $foo = TRUE ?>';
$subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive',
\T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy')
);
$emConf = $subject->_call('extractEmConf', $code);
......@@ -108,7 +112,7 @@ class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
$code = '<?php $EM_CONFOTHER[$_EXTKEY] = array(\'bar\' => \'baz\'); ?>';
$subject = $this->getAccessibleMock(
'Tx_TerFe2_Utility_Archive',
\T3o\TerFe2\Utility\ArchiveUtility::class,
array('dummy')
);
$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