Skip to content

Commit

Permalink
🔧 rm remaining ancient factory references
Browse files Browse the repository at this point in the history
  • Loading branch information
willpower232 committed Dec 24, 2024
1 parent bac86a5 commit 25776eb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"illuminate/filesystem": "^9.0|^10.0|^11.0"
},
"require-dev": {
"laravel/legacy-factories": "*",
"larastan/larastan": "^2.0",
"mockery/mockery": "^1.5.1",
"orchestra/testbench": "^7.22.1|^8.0|^9.0",
Expand Down
48 changes: 24 additions & 24 deletions tests/Functional/AuditingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function itWillRemoveOlderAuditsAboveTheThreshold()
'updated',
]);

$article = factory(Article::class)->create([
$article = Article::factory()->create([
'title' => 'Title #0',
]);

Expand Down Expand Up @@ -462,15 +462,15 @@ public function itDisablesAndEnablesAuditingBackAgainViaWithoutAuditingMethod()
$this->assertFalse(Article::$auditingDisabled);

Article::withoutAuditing(function () {
factory(Article::class)->create();
Article::factory()->create();
});

$this->assertSame(1, Article::count());
$this->assertSame(0, Audit::count());

$this->assertFalse(Article::$auditingDisabled);

factory(Article::class)->create();
Article::factory()->create();

$this->assertSame(2, Article::count());
$this->assertSame(1, Audit::count());
Expand Down Expand Up @@ -667,8 +667,8 @@ public function itWillAuditAttach()
*/
public function itWillNotAuditAttachByInvalidRelationName()
{
$firstCategory = factory(Category::class)->create();
$article = factory(Article::class)->create();
$firstCategory = Category::factory()->create();
$article = Article::factory()->create();

$this->expectExceptionMessage("Relationship invalidRelation was not found or does not support method attach");

Expand Down Expand Up @@ -709,9 +709,9 @@ public function itWillAuditSync()
public function itWillAuditSyncIndividually()
{
Article::disableAuditing();
$user = factory(User::class)->create();
$category = factory(Category::class)->create();
$article = factory(Article::class)->create();
$user = User::factory()->create();
$category = Category::factory()->create();
$article = Article::factory()->create();
Article::enableAuditing();

$no_of_audits_before = Audit::where('auditable_type', Article::class)->count();
Expand Down Expand Up @@ -746,9 +746,9 @@ public function itWillAuditSyncWithPivotValues()
$this->markTestSkipped('This test is only for Laravel 8.0.0+');
}

$firstCategory = factory(Category::class)->create();
$secondCategory = factory(Category::class)->create();
$article = factory(Article::class)->create();
$firstCategory = Category::factory()->create();
$secondCategory = Category::factory()->create();
$article = Article::factory()->create();

$article->categories()->attach([$firstCategory->getKey() => [ 'pivot_type' => 'PIVOT_1' ]]);

Expand Down Expand Up @@ -785,10 +785,10 @@ public function itWillAuditSyncWithPivotValues()
*/
public function itWillAuditSyncByClosure()
{
$firstCategory = factory(Category::class)->create();
$secondCategory = factory(Category::class)->create();
$thirdCategory = factory(Category::class)->create();
$article = factory(Article::class)->create();
$firstCategory = Category::factory()->create();
$secondCategory = Category::factory()->create();
$thirdCategory = Category::factory()->create();
$article = Article::factory()->create();

$article->categories()->attach([$firstCategory->getKey() => [ 'pivot_type' => 'PIVOT_1' ]]);
$article->categories()->attach([$secondCategory->getKey() => [ 'pivot_type' => 'PIVOT_2' ]]);
Expand Down Expand Up @@ -833,9 +833,9 @@ function ($categories) { return $categories->wherePivot('pivot_type', 'PIVOT_1')
*/
public function itWillNotAuditSyncByInvalidClosure()
{
$firstCategory = factory(Category::class)->create();
$secondCategory = factory(Category::class)->create();
$article = factory(Article::class)->create();
$firstCategory = Category::factory()->create();
$secondCategory = Category::factory()->create();
$article = Article::factory()->create();

$article->categories()->attach($firstCategory);

Expand Down Expand Up @@ -884,10 +884,10 @@ public function itWillAuditDetach()
*/
public function itWillAuditDetachByClosure()
{
$firstCategory = factory(Category::class)->create();
$secondCategory = factory(Category::class)->create();
$thirdCategory = factory(Category::class)->create();
$article = factory(Article::class)->create();
$firstCategory = Category::factory()->create();
$secondCategory = Category::factory()->create();
$thirdCategory = Category::factory()->create();
$article = Article::factory()->create();

$article->categories()->attach([$firstCategory->getKey() => [ 'pivot_type' => 'PIVOT_1' ]]);
$article->categories()->attach([$secondCategory->getKey() => [ 'pivot_type' => 'PIVOT_2' ]]);
Expand Down Expand Up @@ -924,8 +924,8 @@ function ($categories) { return $categories->wherePivot('pivot_type', 'PIVOT_1')
*/
public function itWillNotAuditDetachByInvalidClosure()
{
$firstCategory = factory(Category::class)->create();
$article = factory(Article::class)->create();
$firstCategory = Category::factory()->create();
$article = Article::factory()->create();

$article->categories()->attach($firstCategory);

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/AuditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function itReturnsAuditMetadataAsArray()
*/
public function itReturnsProperCommandLineInUrlAuditMetadata()
{
$audit = factory(Article::class)->create()->audits()->first();
$audit = Article::factory()->create()->audits()->first();

$this->assertNotNull($audit);

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/AuditableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ public function itWorksWhenConfigAllowedArrayValueIsTrue()
{
$this->app['config']->set('audit.allowed_array_values', true);

$model = factory(Article::class)->make([
$model = Article::factory()->make([
'title' => 'How To Audit Eloquent Models',
'content' => 'First step: install the laravel-auditing package.',
'reviewed' => 1,
Expand Down Expand Up @@ -1462,7 +1462,7 @@ public function itWorksWhenConfigAllowedArrayValueIsFalse()
{
$this->app['config']->set('audit.allowed_array_values', false);

$model = factory(Article::class)->make([
$model = Article::factory()->make([
'title' => 'How To Audit Eloquent Models',
'content' => 'First step: install the laravel-auditing package.',
'reviewed' => 1,
Expand Down

0 comments on commit 25776eb

Please sign in to comment.