This repository has been archived by the owner on May 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #455 from localheinz/feature/repository-entity
Enhancement: Implement Entity\Repository
- Loading branch information
Showing
11 changed files
with
209 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Application\Entity; | ||
|
||
class Repository | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $owner; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @param string $owner | ||
* @param string $name | ||
*/ | ||
public function __construct($owner, $name) | ||
{ | ||
$this->owner = (string) $owner; | ||
$this->name = (string) $name; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function owner() | ||
{ | ||
return $this->owner; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function name() | ||
{ | ||
return $this->name; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
module/Application/src/Application/Service/GitHubRepositoryFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Application\Service; | ||
|
||
use Application\Entity; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
class GitHubRepositoryFactory implements FactoryInterface | ||
{ | ||
/** | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @return Entity\Repository | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$config = $serviceLocator->get('Config')['project_github_repository']; | ||
|
||
return new Entity\Repository( | ||
$config['owner'], | ||
$config['name'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
module/Application/test/ApplicationTest/Entity/RepositoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace ApplicationTest\Entity; | ||
|
||
use Application\Entity; | ||
use ApplicationTest\Mock\StringCastable; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
class RepositoryTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testConstructorSetsValues() | ||
{ | ||
$owner = 'foo'; | ||
$name = 'bar'; | ||
|
||
$entity = new Entity\Repository( | ||
$owner, | ||
$name | ||
); | ||
|
||
$this->assertSame($owner, $entity->owner()); | ||
$this->assertSame($name, $entity->name()); | ||
} | ||
|
||
public function testConstructorCastsToString() | ||
{ | ||
$owner = new StringCastable('foo'); | ||
$name = new StringCastable('bar'); | ||
|
||
$entity = new Entity\Repository( | ||
$owner, | ||
$name | ||
); | ||
|
||
$this->assertSame((string) $owner, $entity->owner()); | ||
$this->assertSame((string) $name, $entity->name()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
module/Application/test/ApplicationTest/Integration/Service/GitHubRepositoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace ApplicationTest\Integration\Service; | ||
|
||
use Application\Entity; | ||
use ApplicationTest\Integration\Util\Bootstrap; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
* @group Functional | ||
* @coversNothing | ||
*/ | ||
class GitHubRepositoryTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testServiceCanBeRetrieved() | ||
{ | ||
$serviceManager = Bootstrap::getServiceManager(); | ||
|
||
$this->assertInstanceOf( | ||
Entity\Repository::class, | ||
$serviceManager->get('project_github_repository') | ||
); | ||
} | ||
} |
Oops, something went wrong.