diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 46b0011..bc59803 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/Tests/Functional/Dashboard/Provider/PageviewsPerPageTest.php b/Tests/Functional/Dashboard/Provider/PageviewsPerPageTest.php index bdec086..b0cad79 100644 --- a/Tests/Functional/Dashboard/Provider/PageviewsPerPageTest.php +++ b/Tests/Functional/Dashboard/Provider/PageviewsPerPageTest.php @@ -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']); + } } diff --git a/Tests/Functional/Fixtures/BackendUserWithTitleLen.xml b/Tests/Functional/Fixtures/BackendUserWithTitleLen.xml new file mode 100644 index 0000000..ed1b4fa --- /dev/null +++ b/Tests/Functional/Fixtures/BackendUserWithTitleLen.xml @@ -0,0 +1,23 @@ + + + + 10 + 0 + 1366642540 + admin + $1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1 + 1 + 0 + 0 + 0 + 0 + 1366642540 + 0 + 1 + 0 + NULL + 1371033743 + 0 + a:1:{s:8:"titleLen";i:4;} + + diff --git a/Tests/Unit/Domain/Repository/PageviewTest.php b/Tests/Unit/Domain/Repository/PageviewTest.php index 7b4f844..1d5a3a4 100644 --- a/Tests/Unit/Domain/Repository/PageviewTest.php +++ b/Tests/Unit/Domain/Repository/PageviewTest.php @@ -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()); } diff --git a/composer.json b/composer.json index 16a96f7..cbb3800 100644 --- a/composer.json +++ b/composer.json @@ -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, diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..f4dd0f2 --- /dev/null +++ b/infection.json.dist @@ -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 + } + } + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 858b92f..f1bbdbe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,6 +8,7 @@ colors="true" convertErrorsToExceptions="true" convertWarningsToExceptions="true" + executionOrder="default" forceCoversAnnotation="false" processIsolation="false" stopOnError="false"