Skip to content

Commit

Permalink
Change assertEquals to assertSame
Browse files Browse the repository at this point in the history
  • Loading branch information
guidocella committed Dec 28, 2016
1 parent 3a0892a commit 4508fca
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion tests/BelongsToTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testExecuteAssociatesBelongsTo()

$phone = $this->populator->make(Phone::class);

$this->assertEquals(5, $phone->user_id);
$this->assertSame(5, $phone->user_id);
}

public function testExecuteWithOptionalBelongsTo()
Expand Down
20 changes: 10 additions & 10 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@ public function testFactoryStateIsMerged()

protected function assertFactoryDefinitionsAreMerged(Product $product)
{
$this->assertEquals(5, $product->price);
$this->assertSame(5, $product->price);

$this->assertEquals('English name', $product->name);
$this->assertEquals('Spanish name', $product->{'name:es'});
$this->assertEquals('Factory definition name', $product->{'name:es-MX'});
$this->assertEquals('Factory definition name', $product->{'name:es-CO'});
$this->assertSame('English name', $product->name);
$this->assertSame('Spanish name', $product->{'name:es'});
$this->assertSame('Factory definition name', $product->{'name:es-MX'});
$this->assertSame('Factory definition name', $product->{'name:es-CO'});
}

public function testMultipleFactoryStatesAreMerged()
{
$product = $this->populator->add(Product::class)->states('expensive', 'new')
->translationStates('Laravel', 'awesome')->make();

$this->assertEquals(500, $product->price);
$this->assertSame(500, $product->price);
$this->assertEquals(Carbon::today(), $product->created_at);

$this->assertEquals('English name', $product->name);
$this->assertEquals('Laravel', $product->{'name:es-MX'});
$this->assertEquals('This product is awesome', $product->description);
$this->assertSame('English name', $product->name);
$this->assertSame('Laravel', $product->{'name:es-MX'});
$this->assertSame('This product is awesome', $product->description);
}

public function testStateWithoutDefitionIsMerged()
Expand All @@ -82,7 +82,7 @@ public function testStateWithoutDefitionIsMerged()

$user = $this->populator->make(User::class, 'email_state');

$this->assertEquals('[email protected]', $user->email);
$this->assertSame('[email protected]', $user->email);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@ public function testClassState()
{
$user = populator(User::class, 'email')->make();

$this->assertEquals('State email', $user->email);
$this->assertSame('State email', $user->email);
}

public function testClassQuantity() {
$users = populator(User::class, 5)->make();

$this->assertEquals(5, $users->count());
$this->assertSame(5, $users->count());
}

public function testClassStateQuantity()
{
$users = populator(User::class, 'email', 5)->make();

$this->assertEquals('State email', $users[0]->email);
$this->assertEquals(5, $users->count());
$this->assertSame('State email', $users[0]->email);
$this->assertSame(5, $users->count());
}

public function testPassingCustomAttributesToMake()
{
$user = populator(User::class)->make(['email' => 'Overridden email']);

$this->assertEquals('Overridden email', $user->email);
$this->assertSame('Overridden email', $user->email);
}

public function testPassingCustomAttributesToCreate()
{
$user = populator(User::class)->create(['email' => 'Overridden email']);

$this->assertEquals('Overridden email', $user->email);
$this->assertSame('Overridden email', $user->email);
}
}
8 changes: 4 additions & 4 deletions tests/PivotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testCreateAssociatesAllManyToManyRelated()
->add(Role::class, 5)
->create(User::class);

$this->assertEquals(5, $user->roles()->count());
$this->assertSame(5, $user->roles()->count());
}

public function testMorphToManyIsAssociated()
Expand All @@ -64,7 +64,7 @@ public function testAttachQuantities_withExecute()

$user = $this->populator->execute()[User::class];

$this->assertEquals(10, $user->roles()->count());
$this->assertSame(10, $user->roles()->count());
}

public function testAttachQuantities_withCreate()
Expand All @@ -73,7 +73,7 @@ public function testAttachQuantities_withCreate()
->add(Role::class, 20)
->add(User::class)->attachQuantities([Role::class => 10])->create();

$this->assertEquals(10, $user->roles()->count());
$this->assertSame(10, $user->roles()->count());
}

public function testCustomPivotAttributes()
Expand All @@ -88,7 +88,7 @@ public function testCustomPivotAttributes()
],
])->create();

$this->assertEquals('2000-01-11', $user->roles[0]->pivot->expires_at);
$this->assertSame('2000-01-11', $user->roles[0]->pivot->expires_at);
}

public function testSeedRunsOneInsertPer500PivotRows()
Expand Down
14 changes: 7 additions & 7 deletions tests/PopulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function testExecuteCreatesAndReturnsModels()
$this->assertInstanceOf(Collection::class, $models[Post::class]);
$this->assertCount(5, $models[Post::class]);

$this->assertEquals(1, User::count());
$this->assertEquals(5, Post::count());
$this->assertSame(1, User::count());
$this->assertSame(5, Post::count());
}

public function testCreateOne()
Expand All @@ -34,7 +34,7 @@ public function testCreateOne()

$this->assertInstanceOf(User::class, $user);

$this->assertEquals(1, User::count());
$this->assertSame(1, User::count());
}

public function testCreateMany()
Expand All @@ -43,7 +43,7 @@ public function testCreateMany()

$this->assertCount(5, $users);

$this->assertEquals(5, User::count());
$this->assertSame(5, User::count());
}

public function testMakeOne()
Expand Down Expand Up @@ -105,8 +105,8 @@ public function testCustomAttributesPassedToAdd()
},
]);

$this->assertEquals(1, $user->integer);
$this->assertEquals($user->integer, $user->bigint);
$this->assertSame(1, $user->integer);
$this->assertSame($user->integer, $user->bigint);
}

public function testModifiers()
Expand Down Expand Up @@ -163,7 +163,7 @@ public function testSeedReturnsPrimaryKeys()
->add(User::class)
->add(Video::class, 2);

$this->assertEquals(
$this->assertSame(
[
User::class => [1],
Video::class => [2, 1],
Expand Down
16 changes: 8 additions & 8 deletions tests/TranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testTranslation()
// because if they weren't an exception would be thrown since they have no default value.
$product = $this->populator->make(Product::class);

$this->assertEquals(['en', 'es', 'es-MX', 'es-CO'], $product->translations->pluck('locale')->all());
$this->assertSame(['en', 'es', 'es-MX', 'es-CO'], $product->translations->pluck('locale')->all());
}

public function testTranslateIn()
Expand All @@ -34,17 +34,17 @@ public function testTranslateIn()

$models = $this->populator->execute();

$this->assertEquals(['en', 'es-MX'], $models[Product::class]->translations()->pluck('locale')->all());
$this->assertSame(['en', 'es-MX'], $models[Product::class]->translations()->pluck('locale')->all());

$this->assertEquals(['en'], $models[Role::class]->translations()->pluck('locale')->all());
$this->assertSame(['en'], $models[Role::class]->translations()->pluck('locale')->all());
}

public function testCustomTranslationAttributes_forOneLocale()
{
$product = $this->populator->make(Product::class, ['name' => 'English name', 'name:es' => 'Spanish name']);

$this->assertEquals('English name', $product->name);
$this->assertEquals('Spanish name', $product->{'name:es'});
$this->assertSame('English name', $product->name);
$this->assertSame('Spanish name', $product->{'name:es'});
$this->assertNotEquals('English name', $product->{'name:es-MX'});
}

Expand All @@ -62,9 +62,9 @@ public function testCustomTranslationAttributes_forAllLocales()
},
])->create();

$this->assertEquals(1, $product->name);
$this->assertEquals(1, $product->{'name:es'});
$this->assertEquals($product->name, $product->description);
$this->assertSame(1, $product->name);
$this->assertSame(1, $product->{'name:es'});
$this->assertSame($product->name, $product->description);
}

public function testMakeDoesntSetForeignKeysOfTranslations()
Expand Down

0 comments on commit 4508fca

Please sign in to comment.