Skip to content

Commit c7a0628

Browse files
Merge pull request #10 from lucasmichot/feature/master/data-provider
Use a data-provider for tests.
2 parents 516e25d + 34801fb commit c7a0628

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

tests/unit/UuidResolversTest.php

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tests;
44

5+
use Dyrynda\Database\Support\GeneratesUuid;
56
use PHPUnit_Framework_TestCase;
67

78
class UuidResolversTest extends PHPUnit_Framework_TestCase
@@ -13,46 +14,36 @@ class UuidResolversTest extends PHPUnit_Framework_TestCase
1314

1415
public function setUp()
1516
{
16-
$this->generator = $this->getMockForTrait('Dyrynda\Database\Support\GeneratesUuid');
17+
$this->generator = $this->getMockForTrait(GeneratesUuid::class);
1718
}
1819

19-
/** @test */
20-
public function it_handles_uuid_version_1()
21-
{
22-
$this->generator->uuidVersion = 'uuid1';
23-
24-
$this->assertSame('uuid1', $this->generator->resolveUuidVersion());
25-
}
26-
27-
/** @test */
28-
public function it_handles_uuid_version_3()
29-
{
30-
$this->generator->uuidVersion = 'uuid3';
31-
32-
$this->assertSame('uuid3', $this->generator->resolveUuidVersion());
33-
}
34-
35-
/** @test */
36-
public function it_handles_uuid_version_4()
20+
/**
21+
* @see \Tests\UuidResolversTest::it_handles_uuid_versions
22+
* @return array
23+
*/
24+
public function provider_for_it_handles_uuid_versions()
3725
{
38-
$this->generator->uuidVersion = 'uuid4';
39-
40-
$this->assertSame('uuid4', $this->generator->resolveUuidVersion());
26+
return [
27+
['uuid1', 'uuid1'],
28+
['uuid3', 'uuid3'],
29+
['uuid4', 'uuid4'],
30+
['uuid5', 'uuid5'],
31+
['uuid999', 'uuid4'],
32+
];
4133
}
4234

43-
/** @test */
44-
public function it_handles_uuid_version_5()
45-
{
46-
$this->generator->uuidVersion = 'uuid5';
47-
48-
$this->assertSame('uuid5', $this->generator->resolveUuidVersion());
49-
}
5035

51-
/** @test */
52-
public function it_defaults_to_uuid_version_4()
36+
/**
37+
* @test
38+
* @param string $version
39+
* @param string $resolved
40+
*
41+
* @dataProvider \Tests\UuidResolversTest::provider_for_it_handles_uuid_versions
42+
*/
43+
public function it_handles_uuid_versions($version, $resolved)
5344
{
54-
$this->generator->uuidVersion = 'uuid999';
45+
$this->generator->uuidVersion = $version;
5546

56-
$this->assertSame('uuid4', $this->generator->resolveUuidVersion());
47+
$this->assertSame($resolved, $this->generator->resolveUuidVersion());
5748
}
5849
}

0 commit comments

Comments
 (0)