Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Testing Laravel Package

spiral/testing

Testing SDK for Spiral Framework packages. Provides a custom TestCase with a TestApp so you can test packages without a full application setup. Configure root directory and bootloaders, and keep test app config under tests/app. PHP 8.1+, Spiral 3.15+.

View on GitHub
Deep Wiki
Context7
2.12.2

What's Changed

New Contributors

Full Changelog: https://github.com/spiral/testing/compare/2.12.1...2.12.2

2.12.1

What's Changed

New Contributors

Full Changelog: https://github.com/spiral/testing/compare/2.12.0...2.12.1

2.12.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.11.0...2.12.0

2.10.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.9.1...2.10.0

2.9.1

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.9.0...2.9.1

2.9.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.8.3...2.9.0

2.8.3

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.8.2...2.8.3

2.8.2

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.8.1...2.8.2

2.8.1

What's Changed

New Contributors

Full Changelog: https://github.com/spiral/testing/compare/2.8.0...2.8.1

2.8.0

What's Changed

use Spiral\Testing\Attribute\TestScope;
use Spiral\Testing\Tests\TestCase;

final class ExampleTest extends TestCase
{
    #[TestScope('http')]
    public function testIndexAction(): void
    {
        $response = $this->fakeHttp()->get('/');
        $response->assertOk();
    }
}

Full Changelog: https://github.com/spiral/testing/compare/2.7.0...2.8.0

2.7.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.6.4...2.7.0

2.6.4

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.6.3...2.6.4

2.6.3
2.6.2

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.6.1...2.6.2

2.6.1

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.6.0...2.6.1

2.6.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.5.0...2.6.0

2.5.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.4.1...2.5.0

2.4.1

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.4.0...2.4.1

2.4.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.3.1...2.4.0

2.3.1

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/2.3.0...2.3.1

2.3.0

What's Changed

New Contributors

Full Changelog: https://github.com/spiral/testing/compare/2.2.0...2.3.0

2.2.0

What's Changed

config/http.php

return [
    'basePath'   => '/',
    'headers'    => [
        'Content-Type' => 'text/html; charset=UTF-8',
    ],
    'middleware' => [],
];
$this->assertConfigHasFragments('http', [
    'basePath' => '/'
]);

$this->assertConfigHasFragments('http', [
    'headers' => [
        'Content-Type' => 'text/html; charset=UTF-8',
    ],
]);

New Contributors

Full Changelog: https://github.com/spiral/testing/compare/2.1.0...2.2.0

2.1.0

What's Changed

Interaction with Events

protected function setUp(): void
{
    parent::setUp();
    $this->eventDispatcher = $this->fakeEventDispatcher();
}

assertListening

Assert if an event has a listener attached to it.

$this->eventDispatcher->assertListening(SomeEvent::class, SomeListener::class);

assertDispatched

Assert if an event was dispatched based on a truth-test callback.

// Assert if an event dispatched one or more times
$this->eventDispatcher->assertDispatched(SomeEvent::class);


// Assert if an event dispatched one or more times based on a truth-test callback.
$this->eventDispatcher->assertDispatched(SomeEvent::class, static function(SomeEvent $event): bool {
    return $event->someParam === 100;
});

assertDispatchedTimes

Assert if an event was dispatched a number of times.

$this->eventDispatcher->assertDispatchedTimes(SomeEvent::class, 5);

assertNotDispatched

Determine if an event was dispatched based on a truth-test callback.

$this->eventDispatcher->assertNotDispatched(SomeEvent::class);

$this->eventDispatcher->assertNotDispatched(SomeEvent::class, static function(SomeEvent $event): bool {
    return $event->someParam === 100;
});

assertNothingDispatched

Assert that no events were dispatched.

$this->eventDispatcher->assertNothingDispatched();

dispatched

Get all the events matching a truth-test callback.

$this->eventDispatcher->dispatched(SomeEvent::class);

// or

$this->eventDispatcher->dispatched(SomeEvent::class, static function(SomeEvent $event): bool {
    return $event->someParam === 100;
});

hasDispatched

$this->eventDispatcher->hasDispatched(SomeEvent::class);

Full Changelog: https://github.com/spiral/testing/compare/2.0.0...2.1.0

2.0.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/1.2.1...2.0.0

1.3.0

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/1.2.1...1.3.0

2.0-beta

What's Changed

Full Changelog: https://github.com/spiral/testing/compare/1.2.1...2.0.0

1.2.1
  • Replacement TokenTransport registry for fake HTTP requests with actor
1.2.0

What's Changed

$http = $this->fakeHttp();

// Create a file with size - 100kb
$file = $http->getFileFactory()->createFile('foo.txt', 100);

// Create a file with specific content
$file = $http->getFileFactory()->createFileWithContent('foo.txt', 'Hello world');

// Create a fake image 640x480
$image = $http->getFileFactory()->createImage('fake.jpg', 640, 480);

$http->post(uri: '/', files: ['avatar' => $image, 'documents' => [$file]])->assertOk();
// Will replace all buckets into with local adapters
$storage = $this->fakeStorage();

// Do something with storage
// $image = new UploadedFile(...);
// $storage->bucket('uploads')->write(
//    $image->getClientFilename(),
//    $image->getStream()
// );

$uploads = $storage->bucket('uploads');

$uploads->assertExists('image.jpg');
$uploads->assertCreated('image.jpg');

$public = $storage->bucket('public');
$public->assertNotExist('image.jpg');
$public->assertNotCreated('image.jpg');

// $public->delete('file.txt');
$public->assertDeleted('file.txt');
$uploads->assertNotDeleted('file.txt');
$public->assertNotExist('file.txt');

// $public->move('file.txt', 'folder/file.txt');
$public->assertMoved('file.txt', 'folder/file.txt');
$uploads->assertNotMoved('file.txt', 'folder/file.txt');

// $public->copy('file.txt', 'folder/file.txt');
$public->assertCopied('file.txt', 'folder/file.txt');
$uploads->assertNotCopied('file.txt', 'folder/file.txt');

// $public->setVisibility('file.txt', 'public');
$public->assertVisibilityChanged('file.txt');
$uploads->assertVisibilityNotChanged('file.txt');

Full Changelog: https://github.com/spiral/testing/compare/1.1.1...1.2

1.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/spiral/testing/compare/1.1.0...1.1.1

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests