Skip to content

Commit 26039a3

Browse files
committed
Add blog-post Filters
1 parent f101ebc commit 26039a3

9 files changed

Lines changed: 97 additions & 5 deletions

File tree

blog/assert-and-expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Then we got to `Assert::greaterThan()`. In PHPUnit, the argument order is the sa
5959

6060
So if we want to say `$foo is greater than 42`, we have to write `greaterThan(42, $foo)`.
6161

62-
![greaterThan](/blog/assert-and-expect/img-2.jpg)
62+
![Exceed forty-two, $foo must. Sense this, I do.](/blog/assert-and-expect/img-2.jpg)
6363

6464
Looks disgusting, since everywhere else we use mathematical notation like `$foo > 42`.
6565

@@ -124,7 +124,7 @@ This way, at the start of the pipe in `Assert::string()`, we immediately verify
124124

125125
Code takes less space, facades aren't bloated. Now this is what looks truly elegant. Whether it's usable or not — practice will tell.
126126

127-
![Pipe assertions](/blog/assert-and-expect/img-4.jpg)
127+
![Cool. I like it!](/blog/assert-and-expect/img-4.jpg)
128128

129129
---
130130

blog/filters.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Testo. Filters
2+
3+
![Filters](/blog/filters/img-1.jpg)
4+
5+
Filters are needed to narrow down the set of tests to run. In other words, it's the ability to select tests before running them.
6+
7+
Adding filters is one of the important milestones on the road to version 1.0.0
8+
9+
Now we can proudly say that this milestone is closed. Filters are supported at both the framework level and the plugin level.
10+
11+
![Filters in plugin](/blog/filters/img-2.jpg)
12+
13+
**The filtering system in** [Testo](https://github.com/php-internal/testo) **is multi-layered.**
14+
15+
1. **Test Suite** (`--suite` flag) — global level. It's better to immediately specify that we're running **Unit** tests and don't need to go into **Acceptance**. This will cut out a large chunk of work for the next level.
16+
17+
2. **File path** (`--path` flag) — works at the Finder level, when the folder and file structure is simply scanned. Supports wildcards (asterisks, question marks, etc.).
18+
19+
3. Tokenization. Files that passed the previous filters begin to be read and split into tokens.
20+
21+
These tokens are used to search for function, method, and class names. This is not yet file execution and reflection is unavailable here, but we can already understand whether there are tests in these files.
22+
23+
At this stage, the **name filter** for a test or test case works (in CLI: `--filter` flag).
24+
25+
You can specify a short name of a function, method, class, or together (`UserTest::testCreate`), or FQN (fully qualified name) of a function/class/method.
26+
27+
4. After tokenization, files are executed by PHP so we can work with reflection.
28+
29+
At the reflection level, the filter system performs its final actions: it doesn't let through tests or cases that don't match the name filter.
30+
31+
**Filters can be combined.**
32+
33+
Same-type filters are combined with **OR** operator, different-type filters with **AND** operator.
34+
35+
For example:
36+
37+
- if you specify only two files, both will be executed, since they pass the criteria (File1 OR File2)
38+
39+
- if you specify a file path and the name `simpleTest`, only simpleTest from the specified file will be executed.
40+
41+
**Plugin**
42+
43+
On the [plugin](https://plugins.jetbrains.com/plugin/28842-testo) side, you can now click on a test case, a test, or a file and run only what's selected. And [@xepozz](https://boosty.to/xepozz) also added the ability to hide unnecessary stack traces under a spoiler. Looks amazing and very convenient.
44+
45+
![Plugin in action](/blog/filters/img-3.jpg)

blog/filters/img-1.jpg

460 KB
Loading

blog/filters/img-2.jpg

44.4 KB
Loading

blog/filters/img-3.jpg

54 KB
Loading

blog/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ Latest news and articles about Testo.
55
## Articles
66

77
- `2026-01-01` [Assert and Expect](./assert-and-expect.md)
8+
- `2025-11-07` [Filters](./filters.md)
89
- `2025-10-30` [Khinkali](./khinkali.md)

ru/blog/assert-and-expect.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function simpleTest(): void
5858

5959
Т.е. если мы хотим сказать `$foo больше 42`, то надо написать `greaterThan(42, $foo)`.
6060

61-
![greaterThan](/blog/assert-and-expect/img-2-ru.jpg)
61+
![Превосходить сорок два $foo должно, чую я](/blog/assert-and-expect/img-2-ru.jpg)
6262

6363
Выглядит отвратительно, ведь везде используем математическую запись вида `$foo > 42`.
6464

@@ -99,7 +99,7 @@ Assert::true($foo > 42);
9999

100100
- Нет автокомплита по фасаду `Assert`, и нужно помнить про второй фасад. Ну, к этому надо будет просто привыкнуть.
101101

102-
![Мем](/blog/assert-and-expect/img-3.jpg)
102+
![Мем](/blog/assert-and-expect/img-3-ru.jpg)
103103

104104

105105
## Пробуем что-то новое
@@ -123,7 +123,7 @@ Expect::exception(Failure::class)
123123

124124
Код занимает меньше места, фасады не раздутые. Вот это то, что выглядит действительно элегантно. А юзабельно или нет, покажет практика.
125125

126-
![Пайповые ассерты](/blog/assert-and-expect/img-4-ru.jpg)
126+
![Здорово. Мне нравится.](/blog/assert-and-expect/img-4-ru.jpg)
127127

128128

129129
---

ru/blog/filters.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Testo. Фильтры
2+
3+
![Фильтры](/blog/filters/img-1.jpg)
4+
5+
Фильтры нужны для того, чтобы сузить множество запускаемых тестов. Иначе говоря, это возможность сделать выборку по тестам перед их запуском.
6+
7+
Добавление фильтров является одним из важных пунктов на пути к версии 1.0.0
8+
9+
Теперь с гордостью можно сказать, что этот пункт закрыт. Фильтры поддерживаются на уровне фреймворка и на уровне плагина.
10+
11+
![Фильтры в плагине](/blog/filters/img-2.jpg)
12+
13+
**Система фильтрации в** [Testo](https://github.com/php-internal/testo) **многослойная.**
14+
15+
1. **Test Suite** (флаг `--suite`) — глобальный уровень. Лучше сразу обозначить, что мы запускаем **Unit** тест и лезть в **Acceptance** не нужно. Это срежет большой пласт работы для следующего уровня.
16+
17+
2. **Путь до файла** (флаг `--path`) — отрабатывает на уровне Finder'а, когда просто сканируется структура папок и файлов. Поддерживает wildcards (звёздочки, вопросики и т.д.).
18+
19+
3. Токенизация. Файлы, прошедшие предыдущие фильтры начинают читаться и разбиваться на токены.
20+
21+
По этим токенам ищутся имена функций, методов и классов. Это ещё не исполнение файла и рефлексия здесь недоступна, но мы уже можем понять, есть ли в этих файлах тесты.
22+
23+
На этом этапе отрабатывает **фильтр по имени** теста или тест-кейса (в CLI флаг `--filter`).
24+
25+
Можно указать короткое имя функции, метода, класса или вместе (`UserTest::testCreate`), либо FQN (полное имя) функции/класса/метода.
26+
27+
4. После токенизации файлы выполняются пыхой, чтобы мы могли работать с рефлексией.
28+
29+
На уровне рефлексии система фильтров выполняет последние действия: не пропускает дальше те тесты или кейсы, которые не подходят под фильтр по имени.
30+
31+
**Фильтры можно комбинировать.**
32+
33+
Однотипные фильтры комбинируются оператором **ИЛИ**, разнотипные оператором **И**.
34+
35+
Например:
36+
37+
- если указать только два файла, то выполнятся оба, т.к. пройдут по критерию (Файл1 ИЛИ Файл2)
38+
39+
- если указать путь до файла и имя `simpleTest`, то выполнится только simpleTest из указанного файла.
40+
41+
**Плагин**
42+
43+
На стороне [плагина](https://plugins.jetbrains.com/plugin/28842-testo) теперь можно кликнуть на тест-кейс, на тест или на файл и запустить только выбранное. А ещё [@xepozz](https://boosty.to/xepozz) добавил сокрытие ненужных стек-трейсов под спойлер. Выглядит офигенно и очень удобно.
44+
45+
![Плагин в действии](/blog/filters/img-3.jpg)

ru/blog/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
## Статьи
66

77
- `2026-01-01` [Assert и Expect](./assert-and-expect)
8+
- `2025-11-07` [Фильтры](./filters)
89
- `2025-10-30` [Хинкали](./khinkali)

0 commit comments

Comments
 (0)