Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Porządki w testach: śmieci w `$TMPDIR` i `themes/`, zbędne duplikaty, słabe asercje

Closed
#293 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
backend, testing

Research direction

Start with tests/TestCase.php:106-140, then review the listed tests and TwigEnvironmentTest.php:52-74 for the temporary-directory, theme, duplicate, and assertion issues. Run the test suite and compare dynamicpdf-* directories in the system temp directory before and after; check that the run leaves themes/ and storage/fonts unchanged. Done means the stated acceptance criteria pass, but the owner’s decision on the test-scope items is still needed.

Written by the indexing model from the issue text.

Description

code-review good first issue low-priority tooling

Problem

  1. Ślady poza sandboxem.
    • Helper registerViewTemplates()/registerViewLayouts() bez katalogu tworzy sys_get_temp_dir()/dynamicpdf-views-<uniqid>, którego nikt nie usuwa. Każdy przebieg zostawia 2 katalogi, a na tej maszynie jest ich już 166.
    • TwigEnvironmentTest.php:52-74 tworzy themes/dynamicpdf-test-theme w śledzonym katalogu projektu. Sprząta w finally, ale przerwany przebieg zostawia brudne drzewo, a w trakcie motyw widzi panel.
    • Pierwszy przebieg zapisuje ok. 1,4 MB cache fontów do storage/fonts projektu. Katalog jest w .gitignore, ale reguła „Sandbox anything a plugin writes outside its own storage” tego nie obejmuje.
  2. Duplikaty do usunięcia lub scalenia:
    • ListActionsTest.php:50 i PermissionsTest.php:113 – to samo żądanie;
    • ListActionsTest.php:77 i wiersz datasetu w PermissionsTest.php:240 – ten sam strażnik;
    • PermissionsTest.php:17, 24 i wiersze [open the templates list], [open a layout];
    • UnlockEditedLayoutsMigrationTest.php:117 i :104 – ten sam parametr;
    • TwigSyntaxTest.php:29 i :59 – to samo przez formularz;
    • RegisteredViewFallbackTest.php:23 – kruche klasy Tailwind z demo, render w layoucie pokrywa PDFWrapperTest.php:31.
  3. Słabe asercje:
    • CheckCommandTest.php:55 łapie każde „WARN”, a nie ostrzeżenie o inline PHP. Przechodzi z enable_php=false i brakującym font_dir;
    • PreviewHtmlTest.php:18 przeszukuje źródło widoku zamiast wyrenderowanej strony.
  4. Styl: try/catch + $this->fail() zamiast expect(fn)->toThrow(...) (TwigSyntaxTest.php:29-45, CodeFormatTest.php:6-16). LangParityTest.php:5 to it() bez describe().
  5. Do decyzji właściciela (reguła test-scope: bez testów markupu i tekstów): TemplateFormTest.php:8, 21, ViewStatusTest.php:14, 30, 46, PermissionsTest.php:137, 148, RegisteredViewFallbackTest.php:53, BackendPreviewToolsTest.php:20, 62, PreviewActionTest.php:18, 27.

Dowód

  • tests/TestCase.php:106-140 (sys_get_temp_dir() . '/dynamicpdf-views-' . uniqid(), brak sprzątania). ls -d $TMPDIR/dynamicpdf-views-* | wc -l daje 166.
  • Pozostałe pozycje: odczyt kodu testów. Słabą asercję CheckCommandTest.php:55 potwierdza sonda: z enable_php=false i brakującym font_dir test nadal przechodzi.

Skutek

Rosnący śmietnik w katalogu tymczasowym, ryzyko brudnego drzewa projektu, wolniejsza i mniej czytelna suite oraz asercje, które przechodzą z niewłaściwego powodu.

Proponowane rozwiązanie

  • TestCase zapamiętuje katalogi z writeViewFiles() i usuwa je w teardown.
  • Motyw testowy w katalogu tymczasowym przez app()->useThemesPath($tmp) (wzór: spamprotection/tests/Feature/CmsPipelineTest.php:35-44).
  • dompdf.options.font_dir/font_cache na katalog tymczasowy procesu w TestCase::setUpOctoberPlugin() przed parent::.
  • Usunąć lub scalić duplikaty, zaostrzyć dwie asercje, przepisać styl. Decyzja w punkcie 5.

Kryteria akceptacji

  • Liczba katalogów dynamicpdf-* w sys_get_temp_dir() jest taka sama przed i po przebiegu.
  • Przebieg nie zmienia themes/ ani storage/fonts projektu.
  • Zmienione testy czerwienieją po usunięciu pilnowanej logiki.

Powiązane issues

#197 (sugestia sprzątania katalogów), #221/#255 (poprzednie porządki testów), #222, #245.

Dominant language
PHP
Stars
30
Forks
22
Avg merge
19m
Merged PRs (30d)
81

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.