Files
Lesstime/tests/Unit/Service/SharePathResolverTest.php
T
Matthieu 90682e809c feat(integration) : migrate Gitea/BookStack/Zimbra/Share into module (back)
LST-68 (2.6) backend. Behaviour-preserving move of the external integrations
into src/Module/Integration/. All 26 routes and securities unchanged.

- 5 entities (4 *Configuration singletons + TaskBookStackLink) + 5 repositories
  (Domain interfaces + Doctrine impls, bound). TaskBookStackLink.task now
  references TaskInterface (contract).
- Domain (FileSource interface, SharePathResolver, share DTOs + exceptions);
  Infrastructure (GiteaApiService, BookStackApiService, SmbFileSource, 15
  ApiResources, 21 State, 4 Share controllers).
- Cross-module couplings via abstractions: CalDavService (PM) injects
  ZimbraConfigurationRepositoryInterface; PM TaskDocument consumers repointed
  to the module's FileSource/SharePathResolver; Gitea/BookStack State load
  tasks via TaskRepositoryInterface (concrete Project read for integration
  fields — documented). ZimbraTestConnection keeps CalDavService (no build
  cycle). TokenEncryptor stays shared.
- IntegrationModule registered; doctrine mapping added.
- #[Auditable] + Timestampable on the 4 Configuration entities (additive
  migration on the 4 *_configuration tables).

163 tests green, container compiles (no cycle), no route regression, cs-fixer clean.
2026-06-20 20:16:20 +02:00

65 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Service;
use App\Module\Integration\Domain\Exception\InvalidPathException;
use App\Module\Integration\Domain\Service\SharePathResolver;
use PHPUnit\Framework\TestCase;
/**
* @internal
*/
final class SharePathResolverTest extends TestCase
{
private SharePathResolver $resolver;
protected function setUp(): void
{
$this->resolver = new SharePathResolver();
}
public function testNormalizeRelativeKeepsSimplePath(): void
{
self::assertSame('a/b', $this->resolver->normalizeRelative('a/b'));
}
public function testNormalizeRelativeStripsDotsAndSlashes(): void
{
self::assertSame('a/b', $this->resolver->normalizeRelative('/a/./b/'));
}
public function testNormalizeRelativeConvertsBackslashes(): void
{
self::assertSame('a/b', $this->resolver->normalizeRelative('a\b'));
}
public function testNormalizeRelativeRejectsParentTraversal(): void
{
$this->expectException(InvalidPathException::class);
$this->resolver->normalizeRelative('a/../b');
}
public function testNormalizeRelativeRejectsLeadingParent(): void
{
$this->expectException(InvalidPathException::class);
$this->resolver->normalizeRelative('../etc/passwd');
}
public function testFullPathJoinsBaseAndRelative(): void
{
self::assertSame('/Projets/a/b', $this->resolver->fullPath('/Projets', 'a/b'));
}
public function testFullPathWithEmptyBaseAndEmptyRelativeIsRoot(): void
{
self::assertSame('/', $this->resolver->fullPath('', ''));
}
public function testFullPathTrimsBaseSlashes(): void
{
self::assertSame('/Projets/a', $this->resolver->fullPath('/Projets/', 'a'));
}
}