Tests are used as living usage examples as well as regression checks.
Code generation examples
examples/*Test.phpcontains examples of Model construction,
examples/fixtures/*Test/test*.txtcontains expected generated code.
examples directory we can find tests written with PHPUnit,
they have been designed to also be used as living examples.
Each test method is structured in a similar way:
// Describing the model $argument = new Argument('string', 'filename'); // Generating the code $generatedCode = $this->prettyPrinter->generateCode($argument); // Checking it against what's expected $this->assertSame('string $filename', $generatedCode);
Sometimes the expected code is spanned on many lines:
$method = new Method('__construct'); $generatedCode = $this->prettyPrinter->generateCode($method); $this->assertExpectedCode($generatedCode);
assertExpectedCode method uses the current Test Class and method names to
guess the location of a fixture file, where the expected code is.
Those can be found in
Note: Fixture files always have an extra line, which is trimmed before the actual assertion.
When changes are applied to Memio, the following command is executed to make sure no regressions have been introduced: