Skip to content

Commit

Permalink
Fixed tests & docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-eugone committed Jul 5, 2024
1 parent 714b8d2 commit 2159144
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 88 deletions.
4 changes: 2 additions & 2 deletions docs/docs/bridges/symfony-console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ todo
Command
------------------------------------------------------------

The `RunJobCommand <https://github.com/yokai-php/batch-symfony-console/blob/0.x/src/src/RunJobCommand.php>`__
The `RunJobCommand <https://github.com/yokai-php/batch-symfony-console/blob/0.x/src/RunJobCommand.php>`__
can execute any job.

The command accepts 2 arguments:
Expand All @@ -24,7 +24,7 @@ Examples:
Job launcher
------------------------------------------------------------

The `RunCommandJobLauncher <https://github.com/yokai-php/batch-symfony-console/blob/0.x/src/src/RunCommandJobLauncher.php>`__
The `RunCommandJobLauncher <https://github.com/yokai-php/batch-symfony-console/blob/0.x/src/RunCommandJobLauncher.php>`__
execute jobs via an asynchronous symfony command.

The command called is ``yokai:batch:run``, and the command will actually execute the job.
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/bridges/symfony-framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ you will be able to register these using configuration:
.. note::
If you do not configure anything here, you will be using the
`SimpleJobLauncher <https://github.com/yokai-php/batch/blob/0.x/src/src/Launcher/SimpleJobLauncher.php>`__.
`SimpleJobLauncher <https://github.com/yokai-php/batch/blob/0.x/src/Launcher/SimpleJobLauncher.php>`__.

| The ``default`` job launcher, must reference a launcher name, defined in the ``launchers`` list.
| The ``default`` job launcher will be the autowired instance of job launcher when you ask for one.
Expand All @@ -46,9 +46,9 @@ you will be able to register these using configuration:
All ``launchers`` are configured using a DSN, every scheme has it’s own associated factory:

* ``simple://simple``: a `SimpleJobLauncher <https://github.com/yokai-php/batch/blob/0.x/src/src/Launcher/SimpleJobLauncher.php>`__, no configuration allowed
* ``messenger://messenger``: a `DispatchMessageJobLauncher <https://github.com/yokai-php/batch-symfony-messenger/blob/0.x/src/src/DispatchMessageJobLauncher.php>`__, no configuration allowed
* ``console://console``: a `RunCommandJobLauncher <https://github.com/yokai-php/batch-symfony-console/blob/0.x/src/src/RunCommandJobLauncher.php>`__, configurable options:
* ``simple://simple``: a `SimpleJobLauncher <https://github.com/yokai-php/batch/blob/0.x/src/Launcher/SimpleJobLauncher.php>`__, no configuration allowed
* ``messenger://messenger``: a `DispatchMessageJobLauncher <https://github.com/yokai-php/batch-symfony-messenger/blob/0.x/src/DispatchMessageJobLauncher.php>`__, no configuration allowed
* ``console://console``: a `RunCommandJobLauncher <https://github.com/yokai-php/batch-symfony-console/blob/0.x/src/RunCommandJobLauncher.php>`__, configurable options:

* ``log``: the filename where command output will be redirected (defaults to ``batch_execute.log``)

Expand Down Expand Up @@ -129,7 +129,7 @@ Templating
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

| The templating service is used by the
`JobController <https://github.com/yokai-php/batch-symfony-framework/blob/0.x/src/src/UserInterface/Controller/JobController.php>`__
`JobController <https://github.com/yokai-php/batch-symfony-framework/blob/0.x/src/UserInterface/Controller/JobController.php>`__
to render its templates.
| It’s a wrapper around `Twig <https://twig.symfony.com/>`__, for you to control templates used,
and variables passed.
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/core-concepts/item-job/item-processor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ What types of item processors exists?

* From ``symfony/validator`` bridge:

* `SkipInvalidItemProcessor <https://github.com/yokai-php/batch-symfony-validator/blob/0.x/src/src/SkipInvalidItemProcessor.php>`__:
* `SkipInvalidItemProcessor <https://github.com/yokai-php/batch-symfony-validator/blob/0.x/src/SkipInvalidItemProcessor.php>`__:
validate item and throw exception if invalid that will cause item to be skipped.

* From ``symfony/serializer`` bridge:

* `DenormalizeItemProcessor <https://github.com/yokai-php/batch-symfony-serializer/blob/0.x/src/src/DenormalizeItemProcessor.php>`__:
* `DenormalizeItemProcessor <https://github.com/yokai-php/batch-symfony-serializer/blob/0.x/src/DenormalizeItemProcessor.php>`__:
denormalize each item.
* `NormalizeItemProcessor <https://github.com/yokai-php/batch-symfony-serializer/blob/0.x/src/src/NormalizeItemProcessor.php>`__:
* `NormalizeItemProcessor <https://github.com/yokai-php/batch-symfony-serializer/blob/0.x/src/NormalizeItemProcessor.php>`__:
normalize each item.

**Item processors for testing purpose:**
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/core-concepts/item-job/item-reader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ What types of item readers exists?

* From ``openspout/openspout`` bridge:

* `FlatFileReader <https://github.com/yokai-php/batch-openspout/blob/0.x/src/src/Reader/FlatFileReader.php>`__:
* `FlatFileReader <https://github.com/yokai-php/batch-openspout/blob/0.x/src/Reader/FlatFileReader.php>`__:
read from any CSV/ODS/XLSX file.

* From ``doctrine/dbal`` bridge:

* `DoctrineDBALQueryOffsetReader <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/src/DoctrineDBALQueryOffsetReader.php>`__:
* `DoctrineDBALQueryOffsetReader <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/DoctrineDBALQueryOffsetReader.php>`__:
execute an SQL query and iterate over results, using a limit + offset pagination strategy.
* `DoctrineDBALQueryCursorReader <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/src/DoctrineDBALQueryCursorReader.php>`__:
* `DoctrineDBALQueryCursorReader <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/DoctrineDBALQueryCursorReader.php>`__:
execute an SQL query and iterate over results, using a column based cursor strategy.

* From ``doctrine/orm`` bridge:

* `EntityReader <https://github.com/yokai-php/batch-doctrine-orm/blob/0.x/src/src/EntityReader.php>`__:
* `EntityReader <https://github.com/yokai-php/batch-doctrine-orm/blob/0.x/src/EntityReader.php>`__:
read from any Doctrine ORM entity.

**Item readers for testing purpose:**
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/core-concepts/item-job/item-writer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ What types of item writers exists?

* From ``symfony/messenger`` bridge:

* `DispatchEachItemAsMessageWriter <https://github.com/yokai-php/batch-symfony-messenger/blob/0.x/src/src/Writer/DispatchEachItemAsMessageWriter.php>`__:
* `DispatchEachItemAsMessageWriter <https://github.com/yokai-php/batch-symfony-messenger/blob/0.x/src/Writer/DispatchEachItemAsMessageWriter.php>`__:
dispatch each item as a message in a bus.

* From ``doctrine/dbal`` bridge:

* `DoctrineDBALInsertWriter <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/src/DoctrineDBALInsertWriter.php>`__:
* `DoctrineDBALInsertWriter <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/DoctrineDBALInsertWriter.php>`__:
write items by inserting in a table via a Doctrine ``Connection``.
* `DoctrineDBALUpsertWriter <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/src/DoctrineDBALUpsertWriter.php>`__:
* `DoctrineDBALUpsertWriter <https://github.com/yokai-php/batch-doctrine-dbal/blob/0.x/src/DoctrineDBALUpsertWriter.php>`__:
write items by inserting/updating in a table via a Doctrine ``Connection``.

* From ``doctrine/persistence`` bridge:

* `ObjectWriter <https://github.com/yokai-php/batch-doctrine-persistence/blob/0.x/src/src/ObjectWriter.php>`__:
* `ObjectWriter <https://github.com/yokai-php/batch-doctrine-persistence/blob/0.x/src/ObjectWriter.php>`__:
write items to any Doctrine ``ObjectManager``.

* From ``openspout/openspout`` bridge:

* `FlatFileWriter <https://github.com/yokai-php/batch-openspout/blob/0.x/src/src/Writer/FlatFileWriter.php>`__:
* `FlatFileWriter <https://github.com/yokai-php/batch-openspout/blob/0.x/src/Writer/FlatFileWriter.php>`__:
write items to any CSV/ODS/XLSX file.

**Item writers for testing purpose:**
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/core-concepts/job-execution-storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ How do I store my Job Execution?

You should never be forced to store ``JobExecution`` yourself.

This is `JobLauncher <job-launcher>`__\ ’s job to store it whenever
This is the role of the :doc:`JobLauncher</core-concepts/job-launcher>` job to store it whenever
it is required (usually at the beginning and the end of the job
execution).

Expand Down
28 changes: 14 additions & 14 deletions docs/docs/core-concepts/job-parameter-accessor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Job parameter accessor
============================================================

When a job (or a component within a job) can be working with a parameterized value, it can rely on a
`JobParameterAccessorInterface <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/JobParameterAccessorInterface.php>`__
`JobParameterAccessorInterface <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/JobParameterAccessorInterface.php>`__
instance to retrieve that value.

.. code-block:: php
Expand Down Expand Up @@ -33,32 +33,32 @@ What types of parameter accessors exists?

**Built-in parameter accessors:**

* `ChainParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/ChainParameterAccessor.php>`__:
* `ChainParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/ChainParameterAccessor.php>`__:
try multiple parameter accessors, the first that is not failing is used.
* `ClosestJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/ClosestJobExecutionAccessor.php>`__:
* `ClosestJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/ClosestJobExecutionAccessor.php>`__:
try another parameter accessor on each job execution in hierarchy, until not failed.
* `DefaultParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/DefaultParameterAccessor.php>`__:
* `DefaultParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/DefaultParameterAccessor.php>`__:
try accessing parameter using another parameter accessor, use default value if failed.
* `JobExecutionParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/JobExecutionParameterAccessor.php>`__:
extract value from job execution’s `parameters <https://github.com/yokai-php/batch/blob/0.x/src/src/JobParameters.php>`__.
* `JobExecutionSummaryAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/JobExecutionSummaryAccessor.php>`__:
extract value from job execution’s `summary <https://github.com/yokai-php/batch/blob/0.x/src/src/Summary.php>`__.
* `ParentJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/ParentJobExecutionAccessor.php>`__:
* `JobExecutionParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/JobExecutionParameterAccessor.php>`__:
extract value from job execution’s `parameters <https://github.com/yokai-php/batch/blob/0.x/src/JobParameters.php>`__.
* `JobExecutionSummaryAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/JobExecutionSummaryAccessor.php>`__:
extract value from job execution’s `summary <https://github.com/yokai-php/batch/blob/0.x/src/Summary.php>`__.
* `ParentJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/ParentJobExecutionAccessor.php>`__:
use another parameter accessor on job execution’s parent execution.
* `ReplaceWithVariablesParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/ReplaceWithVariablesParameterAccessor.php>`__:
* `ReplaceWithVariablesParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/ReplaceWithVariablesParameterAccessor.php>`__:
use another parameter accessor to get string value, and replace variables before returning.
* `RootJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/RootJobExecutionAccessor.php>`__:
* `RootJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/RootJobExecutionAccessor.php>`__:
use another parameter accessor on job execution’s root execution.
* `SiblingJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/SiblingJobExecutionAccessor.php>`__:
* `SiblingJobExecutionAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/SiblingJobExecutionAccessor.php>`__:
use another parameter accessor on job execution’s sibling execution.
* `StaticValueParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/src/Job/Parameters/StaticValueParameterAccessor.php>`__:
* `StaticValueParameterAccessor <https://github.com/yokai-php/batch/blob/0.x/src/Job/Parameters/StaticValueParameterAccessor.php>`__:
use static value provided at construction.

**Parameter accessors from bridges:**

* From ``symfony/framework-bundle`` bridge:

* `ContainerParameterAccessor <https://github.com/yokai-php/batch-symfony-framework/blob/0.x/src/src/ContainerParameterAccessor.php>`__:
* `ContainerParameterAccessor <https://github.com/yokai-php/batch-symfony-framework/blob/0.x/src/ContainerParameterAccessor.php>`__:
use a parameter from Symfony’s container.

.. seealso::
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/getting-started/with-symfony.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Creating the job class
.. hint::
| When registering jobs with dedicated class, you can use the
`JobWithStaticNameInterface <https://github.com/yokai-php/batch-symfony-framework/blob/0.x/src/src/JobWithStaticNameInterface.php>`__
`JobWithStaticNameInterface <https://github.com/yokai-php/batch-symfony-framework/blob/0.x/src/JobWithStaticNameInterface.php>`__
interface to be able to specify the job name of your service.
| Otherwise, the service id will be used, and in that case, the service id is the FQCN.
Expand Down
3 changes: 1 addition & 2 deletions tests/convention/Documentation/DocFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
use SplFileInfo;

/**
* A Markdown documentation file.
* A Sphinx documentation file.
*/
final class DocFile
{
public function __construct(
public string $package,
public SplFileInfo $file,
/**
* @var array<DocLink>
Expand Down
4 changes: 1 addition & 3 deletions tests/convention/Documentation/DocLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
use SplFileInfo;

/**
* A markdown link in a markdown documentation file.
* A Sphinx link in a Sphinx documentation file.
*/
final class DocLink
{
public function __construct(
public string $label,
public string $package,
public string $uri,
public SplFileInfo $pointsToFile,
public string $branch,
public bool $absolute,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,24 @@
use Yokai\Batch\Storage\JobExecutionStorageInterface;

/**
* Some assertions on markdown documentation files.
* Some assertions on Sphinx documentation files.
*/
final class MarkdownLinksTest extends TestCase
final class DocumentationLinksTest extends TestCase
{
private const DEFAULT_BRANCH = '0.x';

/**
* Ensure that all links in markdown files points to valid internal resources.
* Ensure that all links in Sphinx files points to valid internal resources.
*
* @dataProvider filesWithLinks
*/
public function testInternalLinksAreValid(DocFile $file): void
{
/** @var DocLink $link */
foreach ($file->links as $link) {
if ($link->package !== $file->package) {
self::assertTrue($link->absolute, 'When pointing to another package, links must be absolute.');
}

self::assertNotFalse(
$link->pointsToFile->getRealPath(),
"Link \"{$link->label}\" in \"{$link->pointsToFile->getRealPath()}\"," .
"Link \"{$link->label}\" in \"{$link->pointsToFile->getPathname()}\"," .
" is pointing to \"{$link->uri}\" which reference an internal file that do not exists."
);

Expand All @@ -49,7 +45,7 @@ public function testInternalLinksAreValid(DocFile $file): void
public function filesWithLinks(): iterable
{
/** @var DocFile $file */
foreach (Markdown::listFiles() as $file) {
foreach (Sphinx::listFiles() as $file) {
if (\count($file->links) === 0) {
continue;
}
Expand Down Expand Up @@ -78,7 +74,7 @@ public function testComponentsAreListed(string $filepath, string $interface): vo
}

// Find all links in these files that points to file that implement these interfaces
$file = Markdown::getFile($filepath);
$file = Sphinx::getFile($filepath);
/** @var DocLink $link */
foreach ($file->links as $link) {
if (!\str_ends_with($link->uri, '.php')) {
Expand All @@ -105,31 +101,31 @@ public function testComponentsAreListed(string $filepath, string $interface): vo
public function interfaceRules(): iterable
{
yield 'JobInterface' => [
'docs/batch/domain/job.md',
'docs/docs/core-concepts/job.rst',
JobInterface::class,
];
yield 'JobExecutionStorageInterface' => [
'docs/batch/domain/job-execution-storage.md',
'docs/docs/core-concepts/job-execution-storage.rst',
JobExecutionStorageInterface::class,
];
yield 'JobLauncherInterface' => [
'docs/batch/domain/job-launcher.md',
'docs/docs/core-concepts/job-launcher.rst',
JobLauncherInterface::class,
];
yield 'JobParameterAccessorInterface' => [
'docs/batch/domain/job-parameter-accessor.md',
'docs/docs/core-concepts/job-parameter-accessor.rst',
JobParameterAccessorInterface::class,
];
yield 'ItemReaderInterface' => [
'docs/batch/domain/item-job/item-reader.md',
'docs/docs/core-concepts/item-job/item-reader.rst',
ItemReaderInterface::class,
];
yield 'ItemProcessorInterface' => [
'docs/batch/domain/item-job/item-processor.md',
'docs/docs/core-concepts/item-job/item-processor.rst',
ItemProcessorInterface::class,
];
yield 'ItemWriterInterface' => [
'docs/batch/domain/item-job/item-writer.md',
'docs/docs/core-concepts/item-job/item-writer.rst',
ItemWriterInterface::class,
];
}
Expand Down
Loading

0 comments on commit 2159144

Please sign in to comment.