Skip to content

Commit

Permalink
#226 Adds a test to reproduce the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloelcolombiano committed Sep 27, 2023
1 parent 521f5da commit b445c81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/Factory/ArticleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected function setDefaultTemplate(): void
$this->setDefaultData(function (Generator $faker) {
return [
'title' => $faker->text(120),
'body' => null,
];
})
->withAuthors(null, self::DEFAULT_NUMBER_OF_AUTHORS);
Expand Down
11 changes: 10 additions & 1 deletion tests/TestCase/Factory/BaseFactoryDefaultValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,20 @@ public function testDefaultValuesOfArticleDifferent()
* When creating multiples Authors for an article,
* these authors should be different
*/
public function testDefautlValuesOfArticleAuthorsDifferent()
public function testDefaultValuesOfArticleAuthorsDifferent()
{
$n = 5;
$article = ArticleFactory::make()->withAuthors($n)->getEntity();
$authorNames = Hash::extract($article, 'authors.{n}.name');
$this->assertEquals($n, count(array_unique($authorNames)));
}

public function testDefaultValuesNullGetOriginal()
{
$article = ArticleFactory::make()->without('Authors')->getEntity();
$this->assertNull($article->body);
$bodyContent = 'body';
$article->body = $bodyContent;
$this->assertNull($article->getOriginal('body'));
}
}

0 comments on commit b445c81

Please sign in to comment.