Skip to content

Commit

Permalink
feat(test): implement base of ci with test
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisdugue committed Nov 5, 2024
1 parent 4db7576 commit 2de2597
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ jobs:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

- name: Run PHPUnit
run: bin/phpunit --verbose
run: vendor/bin/phpunit

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ public/index.php
composer.lock
.DS_Store
.thumbs
.phpunit.cache
5 changes: 3 additions & 2 deletions Service/ResultService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Studit\H5PBundle\Entity\ContentResult;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\User\UserInterface;

class ResultService
{
Expand Down Expand Up @@ -53,7 +54,7 @@ public function handleRequestFinished(Request $request, $userId): ContentResult
* remove data in content User Data.
* @param integer $contentId
* @param string $dataType
* @param int|null|string $user Current user
* @param UserInterface $user Current user
* @param integer $subContentId
*/
public function removeData(int $contentId, string $dataType, $user, int $subContentId): void
Expand All @@ -63,7 +64,7 @@ public function removeData(int $contentId, string $dataType, $user, int $subCont
'subContentId' => $subContentId,
'mainContent' => $contentId,
'dataId' => $dataType,
'user' => $user->getId()
'user' => $user->getUserIdentifier()
]
);
if (count($ContentUserData) > 0) {
Expand Down
51 changes: 51 additions & 0 deletions Tests/Event/LibraryFileEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Studit\H5PBundle\Tests\Event;

use PHPUnit\Framework\TestCase;
use Studit\H5PBundle\Event\LibraryFileEvent;

class LibraryFileEventTest extends TestCase
{
public function testGetFiles()
{
// Arrange
$files = ['file1.js', 'file2.css'];
$libraryList = ['library1', 'library2'];
$mode = 'production';

// Act
$event = new LibraryFileEvent($files, $libraryList, $mode);

// Assert
$this->assertSame($files, $event->getFiles());
}

public function testGetLibraryList()
{
// Arrange
$files = ['file1.js', 'file2.css'];
$libraryList = ['library1', 'library2'];
$mode = 'production';

// Act
$event = new LibraryFileEvent($files, $libraryList, $mode);

// Assert
$this->assertSame($libraryList, $event->getLibraryList());
}

public function testGetMode()
{
// Arrange
$files = ['file1.js', 'file2.css'];
$libraryList = ['library1', 'library2'];
$mode = 'production';

// Act
$event = new LibraryFileEvent($files, $libraryList, $mode);

// Assert
$this->assertSame($mode, $event->getMode());
}
}
26 changes: 26 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
shortenArraysForExportThreshold="10"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
displayDetailsOnPhpunitDeprecations="true"
failOnPhpunitDeprecation="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>Tests</directory>
</testsuite>
</testsuites>

<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>.</directory>
</include>
</source>
</phpunit>

0 comments on commit 2de2597

Please sign in to comment.