Skip to content

Commit

Permalink
rename Entity.Page.active to Entity.Page.published
Browse files Browse the repository at this point in the history
  • Loading branch information
mamuz committed Aug 10, 2014
1 parent 6dbf160 commit b02db80
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ Content will be rendered with a markdown parser.

## Workflow

If routing is successful to a page entity found by active flag and path argument,
If routing is successful to a page entity found by published flag and path argument,
page content will be responsed in a new view model. Otherwise it will set a 404 status code
to http response object.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require-dev" : {
"satooshi/php-coveralls": "0.6.*",
"phpunit/phpunit" : "4.1.*",
"phpunit/phpunit" : "4.2.*",
"mockery/mockery" : "0.9.*"
},
"autoload" : {
Expand Down
2 changes: 1 addition & 1 deletion src/MamuzContentManager/Controller/QueryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(QueryInterface $queryService)
public function pageAction()
{
$path = $this->params()->fromRoute('path');
$page = $this->queryService->findActivePageByPath(trim($path, '/'));
$page = $this->queryService->findPublishedPageByPath(trim($path, '/'));

if ($page instanceof NullPage) {
/** @var Response $response */
Expand Down
14 changes: 7 additions & 7 deletions src/MamuzContentManager/Entity/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class Page
/**
* @ORM\Column(type="boolean", nullable=false)
* @Annotation\Filter({"name":"Boolean"})
* @Annotation\Options({"label":"Active"})
* @Annotation\Options({"label":"Publish"})
* @var bool
*/
private $active = false;
private $published = false;

/**
* destroy identity
Expand Down Expand Up @@ -143,20 +143,20 @@ public function getContent()
}

/**
* @param boolean $active
* @param boolean $published
* @return Page
*/
public function setActive($active)
public function setPublished($published)
{
$this->active = $active;
$this->published = $published;
return $this;
}

/**
* @return boolean
*/
public function isActive()
public function isPublished()
{
return $this->active;
return $this->published;
}
}
2 changes: 1 addition & 1 deletion src/MamuzContentManager/Feature/QueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ interface QueryInterface
* @param string $path
* @return Page
*/
public function findActivePageByPath($path);
public function findPublishedPageByPath($path);
}
6 changes: 3 additions & 3 deletions src/MamuzContentManager/Mapper/Db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public function __construct(ObjectRepository $repository)
$this->repository = $repository;
}

public function findActivePageByPath($path)
public function findPublishedPageByPath($path)
{
$page = $this->repository->findOneBy(
array(
'path' => $path,
'active' => true,
'path' => $path,
'published' => true,
)
);

Expand Down
4 changes: 2 additions & 2 deletions src/MamuzContentManager/Service/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public function __construct(QueryInterface $mapper)
$this->mapper = $mapper;
}

public function findActivePageByPath($path)
public function findPublishedPageByPath($path)
{
return $this->mapper->findActivePageByPath($path);
return $this->mapper->findPublishedPageByPath($path);
}
}
10 changes: 2 additions & 8 deletions test/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
<?php

error_reporting(E_ALL | E_STRICT);

if (function_exists('xdebug_disable')) {
xdebug_disable();
}
error_reporting(E_ALL);

$file = __DIR__ . '/../vendor/autoload.php';
if (file_exists($file)) {
$loader = require $file;
}

if (!isset($loader)) {
throw new \RuntimeException(
'vendor/autoload.php could not be found. Did you run `php composer.phar install`?'
);
throw new \RuntimeException('Cannot find vendor/autoload.php');
}

/** @var \Composer\Autoload\ClassLoader $loader */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testQueryActionCanBeAccessed()
$this->page->shouldReceive('getContent')->andReturn($content);

$this->queryInterface
->shouldReceive('findActivePageByPath')
->shouldReceive('findPublishedPageByPath')
->with($this->path)
->andReturn($this->page);

Expand All @@ -87,7 +87,7 @@ public function testQueryActionPageNotFoundByNullPage()
$this->page = \Mockery::mock('MamuzContentManager\Entity\NullPage');

$this->queryInterface
->shouldReceive('findActivePageByPath')
->shouldReceive('findPublishedPageByPath')
->with($this->path)
->andReturn($this->page);

Expand Down
8 changes: 4 additions & 4 deletions test/MamuzContentManagerTest/Entity/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public function testMutateAndAccessContent()
$this->assertSame($result, $this->fixture);
}

public function testMutateAndAccessActive()
public function testMutateAndAccessPublished()
{
$this->assertFalse($this->fixture->isActive());
$result = $this->fixture->setActive(true);
$this->assertTrue($this->fixture->isActive());
$this->assertFalse($this->fixture->isPublished());
$result = $this->fixture->setPublished(true);
$this->assertTrue($this->fixture->isPublished());
$this->assertSame($result, $this->fixture);
}
}
12 changes: 6 additions & 6 deletions test/MamuzContentManagerTest/Mapper/Db/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,38 @@ public function testImplementingQueryInterface()
$this->assertInstanceOf('MamuzContentManager\Feature\QueryInterface', $this->fixture);
}

public function testFindActivePageByPath()
public function testFindPublishedPageByPath()
{
$path = 'foo';
$this->entityRepository
->shouldReceive('findOneBy')
->with(
array(
'path' => $path,
'active' => true,
'published' => true,
)
)
->andReturn($this->entity);

$this->assertSame($this->entity, $this->fixture->findActivePageByPath($path));
$this->assertSame($this->entity, $this->fixture->findPublishedPageByPath($path));
}

public function testFindActivePageByPathWithNullPage()
public function testFindPublishedPageByPathWithNullPage()
{
$path = 'foo';
$this->entityRepository
->shouldReceive('findOneBy')
->with(
array(
'path' => $path,
'active' => true,
'published' => true,
)
)
->andReturn(null);

$this->assertInstanceOf(
'MamuzContentManager\Entity\NullPage',
$this->fixture->findActivePageByPath($path)
$this->fixture->findPublishedPageByPath($path)
);
}
}
6 changes: 3 additions & 3 deletions test/MamuzContentManagerTest/Service/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public function testImplementingQueryInterface()
$this->assertInstanceOf('MamuzContentManager\Feature\QueryInterface', $this->fixture);
}

public function testFindActivePageByPath()
public function testFindPublishedPageByPath()
{
$path = 'foo';
$this->mapper
->shouldReceive('findActivePageByPath')
->shouldReceive('findPublishedPageByPath')
->with($path)
->andReturn($this->entity);

$this->assertSame($this->entity, $this->fixture->findActivePageByPath($path));
$this->assertSame($this->entity, $this->fixture->findPublishedPageByPath($path));
}
}

0 comments on commit b02db80

Please sign in to comment.