Skip to content

Commit

Permalink
Fixed the failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bluepioupiou committed Sep 8, 2019
1 parent 687c511 commit e332d7f
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions tests/Model/DocumentationTest.php
Expand Up @@ -84,7 +84,7 @@ public function testAddFixtureWithMultidimensionalArray(): void

$documentation = new Documentation([]);

$documentation->addFixture('fixtures', ['id' => 1, 'array' => ['name' => 'fixture1', 'color' => 'red']]);
$documentation->addFixture('fixtures', 1, ['id' => 1, 'array' => ['name' => 'fixture1', 'color' => 'red']]);
}

public function testAddFixtureEntity(): void
Expand All @@ -93,7 +93,7 @@ public function testAddFixtureEntity(): void
->makePartial();
$mockFixture->shouldReceive('setLinks')
->once();

$mockDocumentation = Mockery::mock(
Documentation::class,
[
Expand All @@ -107,7 +107,8 @@ public function testAddFixtureEntity(): void
->with('Product', 'Product-1', [
'name' => 'product 1',
'category' => 'category 1'
]);
])
->andReturn($mockFixture);

$product = (new Product())
->setId(1)
Expand All @@ -120,6 +121,11 @@ public function testAddFixtureEntity(): void

public function testAddFixtureEntityWithPublicProperties(): void
{
$mockFixture = Mockery::mock(Fixture::class)
->makePartial();
$mockFixture->shouldReceive('setLinks')
->once();

$mockDocumentation = Mockery::mock(
Documentation::class,
[
Expand All @@ -133,14 +139,16 @@ public function testAddFixtureEntityWithPublicProperties(): void
->with('ProductPublic', 'ProductPublic-1', [
'name' => 'product 1',
'category' => 'category 1'
]);
])
->andReturn($mockFixture);

$product = new ProductPublic();
$product->id = 1;
$product->name = 'product 1';
$product->category = 'category 1';

$mockDocumentation->addFixtureEntity($product);
// We expect 0 because if it has the good parameter it will be catch by the mock
$this->assertCount(0, $mockDocumentation->getSections());
}

Expand All @@ -151,6 +159,11 @@ public function testAddFixtureEntityWithComplexProperties(): void
$mockFixture->shouldReceive('setLinks')
->once();

$mockFixture = Mockery::mock(Fixture::class)
->makePartial();
$mockFixture->shouldReceive('setLinks')
->once();

$mockDocumentation = Mockery::mock(
Documentation::class,
[
Expand All @@ -168,7 +181,8 @@ public function testAddFixtureEntityWithComplexProperties(): void
'name' => 'product 1',
'category' => 'category name',
'tags' => 3
]);
])
->andReturn($mockFixture);

$category = new Category();
$category->name = 'category name';
Expand All @@ -189,6 +203,11 @@ public function testAddFixtureEntityWithComplexProperties(): void
*/
public function testAddFixtureEntityWithNonExistingProperty(): void
{
$mockFixture = Mockery::mock(Fixture::class)
->makePartial();
$mockFixture->shouldReceive('setLinks')
->once();

$mockDocumentation = Mockery::mock(
Documentation::class,
[
Expand All @@ -201,7 +220,8 @@ public function testAddFixtureEntityWithNonExistingProperty(): void
->once()
->with('Product', 'Product-1', [
'category' => 'category 1'
]);
])
->andReturn($mockFixture);

$product = (new Product())
->setId(1)
Expand Down

0 comments on commit e332d7f

Please sign in to comment.