Porządki w testach: śmieci w `$TMPDIR` i `themes/`, zbędne duplikaty, słabe asercje
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
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
Problem
- Ślady poza sandboxem.
- Helper
registerViewTemplates()/registerViewLayouts()bez katalogu tworzysys_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-74tworzythemes/dynamicpdf-test-themew śledzonym katalogu projektu. Sprząta wfinally, ale przerwany przebieg zostawia brudne drzewo, a w trakcie motyw widzi panel.- Pierwszy przebieg zapisuje ok. 1,4 MB cache fontów do
storage/fontsprojektu. Katalog jest w.gitignore, ale reguła „Sandbox anything a plugin writes outside its own storage” tego nie obejmuje.
- Helper
- Duplikaty do usunięcia lub scalenia:
ListActionsTest.php:50iPermissionsTest.php:113– to samo żądanie;ListActionsTest.php:77i wiersz datasetu wPermissionsTest.php:240– ten sam strażnik;PermissionsTest.php:17, 24i wiersze[open the templates list],[open a layout];UnlockEditedLayoutsMigrationTest.php:117i:104– ten sam parametr;TwigSyntaxTest.php:29i:59– to samo przez formularz;RegisteredViewFallbackTest.php:23– kruche klasy Tailwind z demo, render w layoucie pokrywaPDFWrapperTest.php:31.
- Słabe asercje:
CheckCommandTest.php:55łapie każde „WARN”, a nie ostrzeżenie o inline PHP. Przechodzi zenable_php=falsei brakującymfont_dir;PreviewHtmlTest.php:18przeszukuje źródło widoku zamiast wyrenderowanej strony.
- Styl: try/catch +
$this->fail()zamiastexpect(fn)->toThrow(...)(TwigSyntaxTest.php:29-45,CodeFormatTest.php:6-16).LangParityTest.php:5toit()bezdescribe(). - 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 -ldaje 166.- Pozostałe pozycje: odczyt kodu testów. Słabą asercję
CheckCommandTest.php:55potwierdza sonda: zenable_php=falsei brakującymfont_dirtest 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
TestCasezapamiętuje katalogi zwriteViewFiles()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_cachena katalog tymczasowy procesu wTestCase::setUpOctoberPlugin()przedparent::.- Usunąć lub scalić duplikaty, zaostrzyć dwie asercje, przepisać styl. Decyzja w punkcie 5.
Kryteria akceptacji
- Liczba katalogów
dynamicpdf-*wsys_get_temp_dir()jest taka sama przed i po przebiegu. - Przebieg nie zmienia
themes/anistorage/fontsprojektu. - 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
-
module: user interface priority: high severity: minor type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Enhancement] Add a dark-bg Tailwind variantPossibly taken @bd-viget claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
vigetlabs/wordpress-site-starter#306 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Spomky-Labs/pwa-bundle#476 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day