BUG Cant get owner names from a page that is disabled

This commit is contained in:
Stig Lindqvist 2014-02-25 20:34:42 +13:00
parent 5376c3a248
commit 3017712dfb
3 changed files with 27 additions and 28 deletions

View File

@ -132,12 +132,16 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
* @return string
*/
public function getOwnerNames() {
$options = $this->getOptions();
$names = array();
foreach($this->OwnerGroups() as $group) {
if(!$options) {
return '';
}
foreach($options->OwnerGroups() as $group) {
$names[] = $group->getBreadcrumbs(' > ');
}
foreach($this->OwnerUsers() as $group) {
foreach($options->OwnerUsers() as $group) {
$names[] = $group->getName();
}
return implode(', ', $names);

View File

@ -1,26 +0,0 @@
<?php
class ContentReviewTest extends FunctionalTest {
public static $fixture_file = 'contentreview/tests/ContentReviewTest.yml';
public function testOwnerNames() {
$editor = $this->objFromFixture('Member', 'editor');
$this->logInAs($editor);
$page = new Page();
$page->ReviewPeriodDays = 10;
$page->ContentReviewUsers()->push($editor);
$page->write();
$this->assertTrue($page->doPublish());
$this->assertEquals($page->OwnerNames, "Test Editor", 'Test Editor should be the owner');
$page = $this->objFromFixture('Page', 'about');
$page->ContentReviewOwnerID = 0;
$page->write();
$this->assertTrue($page->doPublish());
$this->assertEquals('', $page->OwnerNames);
}
}

View File

@ -4,6 +4,27 @@ class SiteTreeContentReviewTest extends FunctionalTest {
public static $fixture_file = 'contentreview/tests/ContentReviewTest.yml';
public function testOwnerNames() {
$editor = $this->objFromFixture('Member', 'editor');
$this->logInAs($editor);
$page = new Page();
$page->ReviewPeriodDays = 10;
$page->ContentReviewType ='Custom';
$page->ContentReviewUsers()->push($editor);
$page->write();
$this->assertTrue($page->doPublish());
$this->assertEquals($page->OwnerNames, "Test Editor", 'Test Editor should be the owner');
$page = $this->objFromFixture('Page', 'about');
$page->OwnerUsers()->removeAll();
$page->write();
$this->assertTrue($page->doPublish());
$this->assertEquals('', $page->OwnerNames);
}
public function testPermissionsExists() {
$perms = singleton('SiteTreeContentReview')->providePermissions();
$this->assertTrue(isset($perms['EDIT_CONTENT_REVIEW_FIELDS']));