Skip to content

Commit 4e82b11

Browse files
authored
Add auto update count processed item while running job (#79)
* Add auto update count processed item while running job
1 parent 47af0e2 commit 4e82b11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+290
-290
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ jobs:
1010
- uses: actions/checkout@v4
1111
- uses: php-actions/composer@v6 # or alternative dependency management
1212
- uses: php-actions/phpunit@v4
13+
- name: Run PHP CS Fixer
14+
run: php vendor/bin/php-cs-fixer fix --dry-run --diff

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ composer.lock
66
.idea
77
.phpunit.cache
88
.php-version
9+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('src')
5+
//->in('tests')
6+
->files()->name('*.php');
7+
8+
$config = new PhpCsFixer\Config();
9+
$config->setRules([
10+
'@Symfony' => true,
11+
'@Symfony:risky' => true,
12+
'@PSR12' => true,
13+
'array_syntax' => [
14+
'syntax' => 'short',
15+
],
16+
'combine_consecutive_unsets' => true,
17+
'native_function_invocation' => [
18+
'include' => [
19+
'@compiler_optimized',
20+
],
21+
],
22+
'no_extra_blank_lines' => [
23+
'tokens' => [
24+
'break',
25+
'continue',
26+
'extra',
27+
'return',
28+
'throw',
29+
'use',
30+
'parenthesis_brace_block',
31+
'square_brace_block',
32+
'curly_brace_block',
33+
],
34+
],
35+
'ordered_class_elements' => true,
36+
'ordered_imports' => true,
37+
'yoda_style' => [
38+
'equal' => false,
39+
'identical' => false,
40+
'less_and_greater' => false,
41+
'always_move_variable' => false,
42+
],
43+
])
44+
->setRiskyAllowed(true)
45+
->setFinder(
46+
$finder
47+
);
48+
49+
return $config;

.php_cs.dist

Lines changed: 0 additions & 12 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Version 5.3.0
2+
* Added auto update count processed item while running job
3+
14
# Version 5.2.0
25
* Added custom index for job status
36

Tests/DataflowType/Writer/CollectionWriterTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public function testAll()
4444
$embeddedWriter
4545
->expects($matcher)
4646
->method('write')
47-
->with($this->callback(function ($arg) use ($matcher, $values) {
48-
return $arg === $values[$matcher->numberOfInvocations() - 1];
49-
}))
47+
->with($this->callback(fn($arg) => $arg === $values[$matcher->numberOfInvocations() - 1]))
5048
;
5149

5250
$writer = new CollectionWriter($embeddedWriter);

Tests/DataflowType/Writer/PortWriterAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testAll()
1111
{
1212
$value = 'not an array';
1313

14-
$writer = $this->getMockBuilder('\Port\Writer')
14+
$writer = $this->getMockBuilder(\Port\Writer::class)
1515
->onlyMethods(['prepare', 'finish', 'writeItem'])
1616
->getMock()
1717
;

Tests/Manager/ScheduledDataflowManagerTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,10 @@ public function testCreateJobsFromScheduledDataflows()
4949
$this->jobRepository
5050
->expects($matcher)
5151
->method('findPendingForScheduledDataflow')
52-
->with($this->callback(function ($arg) use ($matcher, $scheduled1, $scheduled2) {
53-
switch ($matcher->numberOfInvocations()) {
54-
case 1:
55-
return $arg === $scheduled1;
56-
case 2:
57-
return $arg === $scheduled2;
58-
default:
59-
return false;
60-
}
52+
->with($this->callback(fn($arg) => match ($matcher->numberOfInvocations()) {
53+
1 => $arg === $scheduled1,
54+
2 => $arg === $scheduled2,
55+
default => false,
6156
}))
6257
->willReturnOnConsecutiveCalls(new Job(), null)
6358
;

Tests/Processor/JobProcessorTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,11 @@ public function testProcess()
4444
->expects($matcher)
4545
->method('dispatch')
4646
->with(
47-
$this->callback(function ($arg) use ($job) {
48-
return $arg instanceof ProcessingEvent && $arg->getJob() === $job;
49-
}),
50-
$this->callback(function ($arg) use ($matcher) {
51-
switch ($matcher->numberOfInvocations()) {
52-
case 1:
53-
return $arg === Events::BEFORE_PROCESSING;
54-
case 2:
55-
return $arg === Events::AFTER_PROCESSING;
56-
default:
57-
return false;
58-
}
47+
$this->callback(fn($arg) => $arg instanceof ProcessingEvent && $arg->getJob() === $job),
48+
$this->callback(fn($arg) => match ($matcher->numberOfInvocations()) {
49+
1 => $arg === Events::BEFORE_PROCESSING,
50+
2 => $arg === Events::AFTER_PROCESSING,
51+
default => false,
5952
})
6053
);
6154

Tests/Runner/MessengerDataflowRunnerTest.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,21 @@ public function testRunPendingDataflows()
3939
$this->repository
4040
->expects($matcher)
4141
->method('save')
42-
->with($this->callback(function ($arg) use ($matcher, $job1, $job2) {
43-
switch ($matcher->numberOfInvocations()) {
44-
case 1:
45-
return $arg === $job1;
46-
case 2:
47-
return $arg === $job2;
48-
default:
49-
return false;
50-
}
42+
->with($this->callback(fn($arg) => match ($matcher->numberOfInvocations()) {
43+
1 => $arg === $job1,
44+
2 => $arg === $job2,
45+
default => false,
5146
}))
5247
;
5348

5449
$matcher = $this->exactly(2);
5550
$this->bus
5651
->expects($matcher)
5752
->method('dispatch')
58-
->with($this->callback(function ($arg) use ($matcher, $id1, $id2) {
59-
switch ($matcher->numberOfInvocations()) {
60-
case 1:
61-
return $arg instanceof JobMessage && $arg->getJobId() === $id1;
62-
case 2:
63-
return $arg instanceof JobMessage && $arg->getJobId() === $id2;
64-
default:
65-
return false;
66-
}
53+
->with($this->callback(fn($arg) => match ($matcher->numberOfInvocations()) {
54+
1 => $arg instanceof JobMessage && $arg->getJobId() === $id1,
55+
2 => $arg instanceof JobMessage && $arg->getJobId() === $id2,
56+
default => false,
6757
}))
6858
->willReturnOnConsecutiveCalls(
6959
new Envelope(new JobMessage($id1)),

0 commit comments

Comments
 (0)