Skip to content

Commit

Permalink
chore(tests): update unit tests, drop phpunit coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaseberle committed Feb 6, 2024
1 parent 20263ff commit d4c7317
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 122 deletions.
4 changes: 0 additions & 4 deletions .coveralls.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ jobs:
- run: composer update --no-interaction --no-progress
- run: composer show
- run: composer tests-for:ci
- name: Push to coveralls (master only)
run: |
.build/bin/php-coveralls \
--root_dir=. --env=prod --verbose \
|| true
if: github.ref == 'refs/heads/master' && matrix.php-version == '8.2'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: Upload coveralls result
uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/master' && matrix.php-version == '8.2'
with:
name: Coveralls result
path: ./Build/coveralls-upload.json
unit-tests-lowest:
runs-on: ubuntu-22.04
continue-on-error: true
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

# build, dev, clutter
/Build/yarn-error.log
/Build/.phpunit.result.cache
/Build/.phpunit.*
/Build/node_modules/
/Build/mix-manifest.json
/Build/testing-docker/.env
/Build/clover.xml
/Build/coveralls-upload.json
/Build/AcceptanceReports
/Tests/Acceptance/Support/_generated/
/temp-*/
Expand Down
29 changes: 6 additions & 23 deletions Build/UnitTests.phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../Classes/</directory>
</include>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false" requireCoverageMetadata="false">
<testsuites>
<testsuite name="Cookieman Extension">
<directory>../Tests/Unit</directory>
</testsuite>
</testsuites>
<logging/>
<source>
<include>
<directory suffix=".php">../Classes/</directory>
</include>
</source>
</phpunit>
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![Crowdin](https://badges.crowdin.net/typo3-extension-cookieman/localized.svg)](https://crowdin.com/project/typo3-extension-cookieman)
[![Coverage Status](https://coveralls.io/repos/github/dmind-gmbh/extension-cookieman/badge.svg?branch=master)](https://coveralls.io/github/dmind-gmbh/extension-cookieman?branch=master)
[![Unit Tests](https://github.com/dmind-gmbh/extension-cookieman/workflows/CGL%20&%20unit%20tests/badge.svg?event=push&branch=master)](https://github.com/dmind-gmbh/extension-cookieman/actions)
[![Acceptance Tests](https://github.com/dmind-gmbh/extension-cookieman/workflows/acceptance%20tests/badge.svg?event=push&branch=master)](https://github.com/dmind-gmbh/extension-cookieman/actions)
[![Latest Stable Version](https://poser.pugx.org/dmind/cookieman/v/stable)](https://packagist.org/packages/dmind/cookieman)
Expand Down
45 changes: 19 additions & 26 deletions Tests/Unit/ShownTrackingObjectsViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,11 @@ class ShownTrackingObjectsViewHelperTest extends UnitTestCase
{
use ProphecyTrait;

/**
* @var ShownTrackingObjectsViewHelper
*/
protected $viewHelper;

/**
* fix type annotation
* @var MockObject|StandardVariableProvider
*/
protected $templateVariableContainer;

/**
* @dataProvider settingsProvider
* @test
* @param array $settings
* @param array $expected
*/
public function trackingObjectsByParameter(array $settings, array $expected): void
{
$result = ShownTrackingObjectsViewHelper::shownTrackingObjects(
$settings['groups']['mandatory'],
$settings
);
protected ShownTrackingObjectsViewHelper $viewHelper;

self::assertSame($expected, $result);
}
protected MockObject|StandardVariableProvider $templateVariableContainer;

public function settingsProvider(): array
public static function settingsProvider(): array
{
$_tests[] = [
0 => [
Expand Down Expand Up @@ -113,6 +90,22 @@ public function settingsProvider(): array
return $_tests;
}

/**
* @dataProvider settingsProvider
* @test
* @param array $settings
* @param array $expected
*/
public function trackingObjectsByParameter(array $settings, array $expected): void
{
$result = ShownTrackingObjectsViewHelper::shownTrackingObjects(
$settings['groups']['mandatory'],
$settings
);

self::assertSame($expected, $result);
}

protected function setUp(): void
{
parent::setUp();
Expand Down
90 changes: 42 additions & 48 deletions Tests/Unit/TypoScriptSettingsProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,17 @@
namespace Dmind\Cookieman\Tests\Unit;

use Dmind\Cookieman\DataProcessing\TypoScriptSettingsProcessor;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class TypoScriptSettingsProcessorTest extends UnitTestCase
{
/**
* @var ContentObjectRenderer|\PHPUnit\Framework\MockObject\MockObject
*/
protected $contentObjectRenderer;

/**
* Sets up this testcase
*/
protected function setUp(): void
{
parent::setUp();
$this->contentObjectRenderer = $this->getMockBuilder(ContentObjectRenderer::class)
->getMock();
}
protected ContentObjectRenderer|MockObject $contentObjectRenderer;

/**
* @dataProvider settingsProvider
* @test
* @param array $pluginConfiguration
* @param array $returnedSettings
*/
public function returnsSettings(array $pluginConfiguration, array $returnedSettings): void
{
$configurationManager = $this->getMockBuilder(ConfigurationManager::class)
->disableOriginalConstructor()
->getMock();
$configurationManager->expects(self::once())->method('getConfiguration')->willReturn(
$pluginConfiguration
);

$subject = $this->getMockBuilder(TypoScriptSettingsProcessor::class)
->setConstructorArgs([$configurationManager])
->setMethods(['getConfigurationManager']) // setMethods() for PHPUnit 6.5
->getMock();

$result = $subject->process(
$this->contentObjectRenderer,
[],
[],
['data' => []]
);

self::assertSame(
$returnedSettings,
$result
);
}

public function settingsProvider()
public static function settingsProvider()
{
return [
[
Expand Down Expand Up @@ -168,4 +124,42 @@ public function settingsProvider()
],
];
}

/**
* @dataProvider settingsProvider
* @test
* @param array $pluginConfiguration
* @param array $returnedSettings
* @throws InvalidConfigurationTypeException
*/
public function returnsSettings(array $pluginConfiguration, array $returnedSettings): void
{
$configurationManager = $this->getMockBuilder(ConfigurationManager::class)
->disableOriginalConstructor()
->getMock();
$configurationManager->expects(self::once())->method('getConfiguration')->willReturn(
$pluginConfiguration
);

$subject = new TypoScriptSettingsProcessor($configurationManager);

$result = $subject->process(
$this->contentObjectRenderer,
[],
[],
['data' => []]
);

self::assertSame(
$returnedSettings,
$result
);
}

protected function setUp(): void
{
parent::setUp();
$this->contentObjectRenderer = $this->getMockBuilder(ContentObjectRenderer::class)
->getMock();
}
}
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
"dmind/cookieman-test-bootstrap5-modal": "@dev",
"friendsofphp/php-cs-fixer": "^3.14",
"helhum/typo3-console": "^8.0",
"php-coveralls/php-coveralls": "^2.1",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5.25",
"phpspec/prophecy-phpunit": "^2.1",
"phpunit/phpunit": "^10.5",
"typo3/cms-install": "^12 || 12.*.x-dev || dev-main",
"typo3/cms-tstemplate": "^12 || 12.*.x-dev || dev-main",
"typo3/tailor": "^1.3",
Expand Down

0 comments on commit d4c7317

Please sign in to comment.