Commit fd919010 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Merge branch 'tests/create-and-adapt-first-unit-tests' into 'develop'

Tests/create and adapt first unit tests

See merge request t3o/ter!300
parents 02a865d0 e09dc714
Pipeline #3452 passed with stages
in 6 minutes and 15 seconds
......@@ -12,10 +12,28 @@ before_script:
stages:
- dump
- test
- build
- layout
- deploy
test:
stage: test
image: php:7.0-alpine
variables:
GIT_STRATEGY: "clone"
GIT_SUBMODULE_STRATEGY: "recursive"
before_script:
- apk add git --update
- export TYPO3_PATH_WEB="$PWD/html"
- export COMPOSER_CACHE_DIR=.cache/composer
- php -r "copy('https://getcomposer.org/composer.phar', 'composer.phar');"
- php composer.phar install
- mkdir $TYPO3_PATH_WEB/fileadmin/ && touch $TYPO3_PATH_WEB/fileadmin/currentcoredata.json
script:
- php composer.phar test:unit
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>
......@@ -55,5 +55,11 @@
"html/typo3conf/ext/ter_fe2/Classes/",
"html/typo3conf/ext/ter/"
]
},
"scripts": {
"test:unit": [
"[ -e bin/phpunit ] || composer install",
"./bin/phpunit -c .gitlab-ci/Tests/UnitTests.xml"
]
}
}
......@@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Utility\VersionNumberUtility;
class LTSVersionService
{
/**
* @var string
* @var array
*/
public $coreData = '';
......
<?php
namespace T3o\TerFe2\Tests\Unit\Domain\Model;
/*******************************************************************
* Copyright notice
*
......@@ -23,20 +25,23 @@
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
use T3o\TerFe2\Domain\Model\Extension;
/**
* 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();
parent::setUp();
$this->fixture = new \T3o\TerFe2\Domain\Model\Extension();
$this->addVersionsToExtension($this->fixture);
}
......@@ -45,10 +50,18 @@ 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
*/
private function addVersionsToExtension(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 +105,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 +114,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());
......
......@@ -79,13 +79,13 @@ class LTSVersionServiceTest extends UnitTestCase
$versions = [
'7' => [
'releases' => [
'7.6.23' => [
'7.6.21' => [
'version' => '7.6.21'
],
'7.6.22' => [
'7.6.20' => [
'version' => '7.6.20'
],
'7.6.21' => [
'7.6.19' => [
'version' => '7.6.19'
],
]
......
<?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,8 +63,8 @@ class Tx_TerFe2_Test_Task_CheckForOutdatedExtensionsTest extends tx_phpunit_test
public function setUp()
{
$this->subject = $this->getAccessibleMock(
'Tx_TerFe2_Task_CheckForOutdatedExtensions',
array('dummy')
\T3o\TerFe2\Task\CheckForOutdatedExtensions::class,
['dummy'], [], '', false
);
}
......@@ -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);
......
Supports Markdown
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