Skip to content

Commit 4d570fa

Browse files
committed
More tests.
1 parent 6200d4a commit 4d570fa

File tree

8 files changed

+592
-102
lines changed

8 files changed

+592
-102
lines changed

CONTRIBUTING.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Contributing to djot-php
2+
3+
Thank you for your interest in contributing to djot-php!
4+
5+
## Getting Started
6+
7+
```bash
8+
# Clone the repository
9+
git clone https://github.com/php-collective/djot-php.git
10+
cd djot-php
11+
12+
# Install dependencies
13+
composer install
14+
```
15+
16+
## Development Workflow
17+
18+
### Running Tests
19+
20+
```bash
21+
# Run all tests
22+
composer test
23+
24+
# Run only project tests (excludes official djot spec tests)
25+
vendor/bin/phpunit --testsuite own
26+
27+
# Run only the official djot test suite
28+
vendor/bin/phpunit --testsuite official
29+
30+
# Run a specific test file
31+
vendor/bin/phpunit tests/TestCase/DjotConverterTest.php
32+
33+
# Run a specific test method
34+
vendor/bin/phpunit --filter testHeading
35+
```
36+
37+
### Test Suites
38+
39+
| Suite | Description |
40+
|-------|-------------|
41+
| `default` | All tests |
42+
| `own` | Project tests only (recommended for development) |
43+
| `official` | Official djot specification tests |
44+
45+
The `own` suite excludes the official test suite which may have expected failures due to implementation differences.
46+
47+
### Code Style
48+
49+
This project follows PHP Collective coding standards.
50+
51+
```bash
52+
# Check code style
53+
composer cs-check
54+
55+
# Auto-fix code style issues
56+
composer cs-fix
57+
```
58+
59+
### Static Analysis
60+
61+
```bash
62+
# Run PHPStan (level 8)
63+
composer stan
64+
```
65+
66+
### Full Check
67+
68+
```bash
69+
# Run all checks (code style + tests)
70+
composer check
71+
```
72+
73+
## Project Structure
74+
75+
```
76+
src/
77+
├── DjotConverter.php # Main entry point
78+
├── Parser/
79+
│ ├── BlockParser.php # Block-level parsing
80+
│ └── InlineParser.php # Inline content parsing
81+
├── Renderer/
82+
│ ├── HtmlRenderer.php # HTML output
83+
│ ├── PlainTextRenderer.php
84+
│ └── MarkdownRenderer.php
85+
├── Node/ # AST node classes
86+
│ ├── Block/ # Block-level nodes
87+
│ └── Inline/ # Inline nodes
88+
└── Event/
89+
└── RenderEvent.php # Render customization events
90+
```
91+
92+
## Writing Tests
93+
94+
Tests are located in `tests/TestCase/`. Follow the existing patterns:
95+
96+
```php
97+
public function testFeatureName(): void
98+
{
99+
$djot = "input text";
100+
$expected = "<p>expected output</p>\n";
101+
102+
$this->assertSame($expected, $this->converter->convert($djot));
103+
}
104+
```
105+
106+
For tests that check partial output:
107+
108+
```php
109+
public function testFeatureContains(): void
110+
{
111+
$result = $this->converter->convert($djot);
112+
113+
$this->assertStringContainsString('expected part', $result);
114+
}
115+
```
116+
117+
## Pull Request Guidelines
118+
119+
1. Create a feature branch from `master`
120+
2. Write tests for new functionality
121+
3. Ensure all tests pass: `vendor/bin/phpunit --testsuite own`
122+
4. Ensure code style passes: `composer cs-check`
123+
5. Ensure PHPStan passes: `composer stan`
124+
6. Submit a pull request with a clear description
125+
126+
## Reporting Issues
127+
128+
When reporting bugs, please include:
129+
130+
- PHP version
131+
- Minimal djot input that reproduces the issue
132+
- Expected output
133+
- Actual output
134+
135+
## Resources
136+
137+
- [Djot Syntax Reference](https://djot.net/)
138+
- [Official Djot Repository](https://github.com/jgm/djot)
139+
- [Project Documentation](docs/README.md)

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<testsuites>
99
<testsuite name="default">
1010
<directory>tests/</directory>
11+
</testsuite>
12+
<testsuite name="own">
13+
<directory>tests/</directory>
1114
<exclude>tests/OfficialTestSuiteTest.php</exclude>
1215
</testsuite>
1316
<testsuite name="official">

0 commit comments

Comments
 (0)