mirror of
https://github.com/archtechx/jobpipeline.git
synced 2025-12-12 09:34:04 +00:00
Add return typehint to shouldBeQueued(), @test -> #[Test], migrate phpunit configuration
This commit is contained in:
parent
a987f8ff69
commit
c4ba5ef04c
4 changed files with 22 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
|||
/vendor/
|
||||
.phpunit.cache/
|
||||
composer.lock
|
||||
.phpunit.result.cache
|
||||
.php-cs-fixer.cache
|
||||
|
|
|
|||
18
phpunit.xml
18
phpunit.xml
|
|
@ -1,13 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<file>./src/routes.php</file>
|
||||
</exclude>
|
||||
</coverage>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
|
|
@ -24,4 +16,12 @@
|
|||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="AWS_DEFAULT_REGION" value="us-west-2"/>
|
||||
</php>
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<file>./src/routes.php</file>
|
||||
</exclude>
|
||||
</source>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class JobPipeline implements ShouldQueue
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function shouldBeQueued(bool $shouldBeQueued = true)
|
||||
public function shouldBeQueued(bool $shouldBeQueued = true): self
|
||||
{
|
||||
$this->shouldBeQueued = $shouldBeQueued;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Orchestra\Testbench\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Spatie\Valuestore\Valuestore;
|
||||
use Stancl\JobPipeline\JobPipeline;
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->valuestore = Valuestore::make(__DIR__ . '/tmp/jobpipelinetest.json')->flush();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function job_pipeline_can_listen_to_any_event()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
|
|
@ -42,7 +43,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertSame('bar', $this->valuestore->get('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function job_pipeline_can_be_queued()
|
||||
{
|
||||
Queue::fake();
|
||||
|
|
@ -63,7 +64,7 @@ class JobPipelineTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function job_pipelines_run_when_queued()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
|
|
@ -81,7 +82,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertSame('bar', $this->valuestore->get('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function job_pipeline_executes_jobs_and_passes_the_object_sequentially()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
|
|
@ -98,7 +99,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertSame('first job changed property', $this->valuestore->get('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function send_can_return_multiple_arguments()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
|
|
@ -114,7 +115,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertSame(['a', 'b'], app('test_args'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function the_pipeline_can_be_canceled_by_returning_false_from_any_job()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
|
|
@ -135,7 +136,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertFalse($this->valuestore->has('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function the_pipeline_can_execute_failed_method_on_job()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
|
|
@ -151,7 +152,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertEquals($this->valuestore->get('exeception'), 'pipeline exception');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function closures_can_be_used_as_jobs()
|
||||
{
|
||||
$passes = false;
|
||||
|
|
@ -169,7 +170,7 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertTrue($passes);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function failures_in_closures_will_throw_correctly()
|
||||
{
|
||||
$this->expectExceptionMessage('foobar');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue