mirror of
https://github.com/DanielSiepmann/tracking.git
synced 2024-12-21 16:06:09 +01:00
WIP|Add mutation testing
Allows to check whether tests cover code manipulation. WIP: * Fix existing issues Resolves: #27
This commit is contained in:
parent
1c669f52c7
commit
17a0f7589d
7 changed files with 135 additions and 2 deletions
49
.github/workflows/ci.yaml
vendored
49
.github/workflows/ci.yaml
vendored
|
@ -23,6 +23,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: PHP lint
|
||||
|
@ -44,6 +45,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -84,6 +86,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -117,6 +120,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "7.4"
|
||||
|
||||
- name: Install xmllint
|
||||
|
@ -154,6 +158,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "7.4"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -191,6 +196,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -232,6 +238,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -272,6 +279,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -322,6 +330,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -354,6 +363,44 @@ jobs:
|
|||
export typo3DatabasePassword="root"
|
||||
./vendor/bin/phpunit --testdox
|
||||
|
||||
mutationtesting:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- tests-sqlite-TYPO3-v10
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- '7.4'
|
||||
typo3-version:
|
||||
- '^10.4'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
coverage: pcov
|
||||
ini-values: pcov.directory=Classes
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
|
||||
- name: Mutation Testing
|
||||
run: ./vendor/bin/infection --show-mutations --min-msi=100 --min-covered-msi=100 --no-progress -j$(nproc)
|
||||
|
||||
code-quality-TYPO3-v10:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
|
@ -370,6 +417,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
@ -410,6 +458,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
|
|
|
@ -296,4 +296,37 @@ class PageviewsPerPageTest extends TestCase
|
|||
], $result['labels']);
|
||||
static::assertCount(3, $result['datasets'][0]['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function shortensTitleBasedOnUserSettings(): void
|
||||
{
|
||||
$this->importDataSet('EXT:tracking/Tests/Functional/Fixtures/Pages.xml');
|
||||
$this->importDataSet('EXT:tracking/Tests/Functional/Fixtures/BackendUserWithTitleLen.xml');
|
||||
$this->setUpBackendUser(10);
|
||||
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$connection->insert('tx_tracking_pageview', [
|
||||
'pid' => $i,
|
||||
'crdate' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
$subject = new PageviewsPerPage(
|
||||
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
|
||||
GeneralUtility::makeInstance(PageRepository::class)
|
||||
);
|
||||
|
||||
$result = $subject->getChartData();
|
||||
static::assertSame([
|
||||
'Page...',
|
||||
'Page...',
|
||||
'Page...',
|
||||
'Page...',
|
||||
'Page...',
|
||||
'Page...',
|
||||
], $result['labels']);
|
||||
static::assertCount(6, $result['datasets'][0]['data']);
|
||||
}
|
||||
}
|
||||
|
|
23
Tests/Functional/Fixtures/BackendUserWithTitleLen.xml
Normal file
23
Tests/Functional/Fixtures/BackendUserWithTitleLen.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<be_users>
|
||||
<uid>10</uid>
|
||||
<pid>0</pid>
|
||||
<tstamp>1366642540</tstamp>
|
||||
<username>admin</username>
|
||||
<password>$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1</password> <!-- password -->
|
||||
<admin>1</admin>
|
||||
<disable>0</disable>
|
||||
<starttime>0</starttime>
|
||||
<endtime>0</endtime>
|
||||
<options>0</options>
|
||||
<crdate>1366642540</crdate>
|
||||
<cruser_id>0</cruser_id>
|
||||
<workspace_perms>1</workspace_perms>
|
||||
<deleted>0</deleted>
|
||||
<TSconfig>NULL</TSconfig>
|
||||
<lastlogin>1371033743</lastlogin>
|
||||
<workspace_id>0</workspace_id>
|
||||
<uc>a:1:{s:8:"titleLen";i:4;}</uc>
|
||||
</be_users>
|
||||
</dataset>
|
|
@ -82,7 +82,7 @@ class PageviewTest extends TestCase
|
|||
/**
|
||||
* @test
|
||||
*/
|
||||
public function throwsExceptionIfModelToUodateHasNoUid(): void
|
||||
public function throwsExceptionIfModelToUpdateHasNoUid(): void
|
||||
{
|
||||
$connection = $this->prophesize(Connection::class);
|
||||
$factory = $this->prophesize(Factory::class);
|
||||
|
@ -91,7 +91,9 @@ class PageviewTest extends TestCase
|
|||
$model->getUid()->willReturn(0);
|
||||
|
||||
$subject = new Pageview($connection->reveal(), $factory->reveal());
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Can not update pageview if uid is 0.');
|
||||
$this->expectExceptionCode(1585770573);
|
||||
$subject->update($model->reveal());
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"typo3/testing-framework": "^6.8.2",
|
||||
"saschaegerer/phpstan-typo3": "^0.13.1",
|
||||
"symplify/easy-coding-standard": "^9.3"
|
||||
"symplify/easy-coding-standard": "^9.3",
|
||||
"infection/infection": "^0.23.0"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
|
|
24
infection.json.dist
Normal file
24
infection.json.dist
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"source": {
|
||||
"directories": [
|
||||
"Classes"
|
||||
]
|
||||
},
|
||||
"logs": {
|
||||
"text": ".Build\/infection"
|
||||
},
|
||||
"mutators": {
|
||||
"@default": true,
|
||||
"CastArray": false,
|
||||
"CastBool": false,
|
||||
"CastFloat": false,
|
||||
"CastInt": false,
|
||||
"CastObject": false,
|
||||
"CastString": false,
|
||||
"MBString": {
|
||||
"settings": {
|
||||
"mb_stripos": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
executionOrder="default"
|
||||
forceCoversAnnotation="false"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
|
|
Loading…
Reference in a new issue