Skip to content

Commit

Permalink
[minor] add missing ->expectDeprecation() to legacy tests (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond authored Aug 20, 2021
1 parent 1647e1b commit 468e80b
Showing 2 changed files with 30 additions and 2 deletions.
27 changes: 26 additions & 1 deletion tests/Functional/RepositoryProxyTest.php
Original file line number Diff line number Diff line change
@@ -31,12 +31,37 @@ public function functions_calls_are_passed_to_underlying_repository(): void

/**
* @test
* @group legacy
*/
public function assertions(): void
{
$repository = repository(Category::class);

$repository->assert()->empty();

CategoryFactory::createMany(2);

$repository->assert()->count(2);
$repository->assert()->countGreaterThan(1);
$repository->assert()->countGreaterThanOrEqual(2);
$repository->assert()->countLessThan(3);
$repository->assert()->countLessThanOrEqual(2);
}

/**
* @test
* @group legacy
*/
public function assertions_legacy(): void
{
$repository = repository(Category::class);

$this->expectDeprecation('Since zenstruck\foundry 1.8.0: Using RepositoryProxy::assertEmpty() is deprecated, use RepositoryProxy::assert()->empty().');
$this->expectDeprecation('Since zenstruck\foundry 1.8.0: Using RepositoryProxy::assertCount() is deprecated, use RepositoryProxy::assert()->count().');
$this->expectDeprecation('Since zenstruck\foundry 1.8.0: Using RepositoryProxy::assertCountGreaterThan() is deprecated, use RepositoryProxy::assert()->countGreaterThan().');
$this->expectDeprecation('Since zenstruck\foundry 1.8.0: Using RepositoryProxy::assertCountGreaterThanOrEqual() is deprecated, use RepositoryProxy::assert()->countGreaterThanOrEqual().');
$this->expectDeprecation('Since zenstruck\foundry 1.8.0: Using RepositoryProxy::assertCountLessThan() is deprecated, use RepositoryProxy::assert()->countLessThan().');
$this->expectDeprecation('Since zenstruck\foundry 1.8.0: Using RepositoryProxy::assertCountLessThanOrEqual() is deprecated, use RepositoryProxy::assert()->countLessThanOrEqual().');

$repository->assertEmpty();

CategoryFactory::createMany(2);
5 changes: 4 additions & 1 deletion tests/Unit/ModelFactoryTest.php
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
namespace Zenstruck\Foundry\Tests\Unit;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Tests\Fixtures\Factories\PostFactory;

@@ -11,7 +12,7 @@
*/
final class ModelFactoryTest extends TestCase
{
use Factories;
use ExpectDeprecationTrait, Factories;

/**
* @test
@@ -46,6 +47,8 @@ public function can_instantiate(): void
*/
public function can_instantiate_many_legacy(): void
{
$this->expectDeprecation(\sprintf('Since zenstruck/foundry 1.7: Calling instance method "%1$s::createMany()" is deprecated and will be removed in 2.0, use the static "%1$s:createMany()" method instead.', PostFactory::class));

$objects = PostFactory::new(['body' => 'body'])->createMany(2, ['title' => 'title']);

$this->assertCount(2, $objects);

0 comments on commit 468e80b

Please sign in to comment.