forked from CouscousPHP/Couscous
-
Notifications
You must be signed in to change notification settings - Fork 0
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 CouscousPHP#138 from leoruhland/feature/cname-meta…
…data Add metadata to generate a CNAME file
- Loading branch information
Showing
7 changed files
with
90 additions
and
6 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,22 @@ | ||
<?php | ||
|
||
namespace Couscous\Module\Core\Step; | ||
|
||
use Couscous\Model\Project; | ||
use Couscous\Module\Template\Model\CnameFile; | ||
use Couscous\Step; | ||
|
||
/** | ||
* Add the CNAME file to project. | ||
* | ||
* @author Leonardo Ruhland <[email protected]> | ||
*/ | ||
class AddCname implements Step | ||
{ | ||
public function __invoke(Project $project) | ||
{ | ||
if (isset($project->metadata['cname'])) { | ||
$project->addFile(new CnameFile('CNAME', $project->metadata['cname'])); | ||
} | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Couscous\Module\Template\Model; | ||
|
||
use Couscous\Model\File; | ||
|
||
/** | ||
* @author Leonardo Ruhland <[email protected]> | ||
*/ | ||
class CnameFile extends File | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $content; | ||
|
||
public function __construct($relativeFilename, $content) | ||
{ | ||
parent::__construct($relativeFilename); | ||
|
||
$this->content = $content; | ||
} | ||
|
||
public function getContent() | ||
{ | ||
return $this->content; | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace Couscous\Tests\UnitTest\Module\Template\Step; | ||
|
||
use Couscous\Model\Metadata; | ||
use Couscous\Model\Project; | ||
use Couscous\Module\Core\Step\AddCname; | ||
|
||
/** | ||
* @covers \Couscous\Model\Project | ||
*/ | ||
class AddCnameTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_should_add_the_cname_file() | ||
{ | ||
$project = new Project('foo', 'bar'); | ||
|
||
$project->metadata = new Metadata(); | ||
$project->metadata['cname'] = 'http://www.couscous.io'; | ||
|
||
$step = new AddCname(); | ||
$step->__invoke($project); | ||
|
||
$cnameFiles = $project->findFilesByType('Couscous\Module\Template\Model\CnameFile'); | ||
|
||
$this->assertCount(1, $cnameFiles); | ||
|
||
$this->assertEquals($cnameFiles['CNAME']->content, $project->metadata['cname']); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.