mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
Fix unit tests
This commit is contained in:
parent
38c489c931
commit
742724dad4
@ -35,7 +35,7 @@ class GoogleSitemapExtension extends DataExtension
|
||||
}
|
||||
|
||||
if ($can) {
|
||||
$can = $this->owner->getGooglePriority();
|
||||
$can = ($this->owner->getGooglePriority() !== false);
|
||||
}
|
||||
|
||||
if ($can === false) {
|
||||
@ -81,8 +81,10 @@ class GoogleSitemapExtension extends DataExtension
|
||||
{
|
||||
$field = $this->owner->hasField('Priority');
|
||||
|
||||
if (isset($this->Priority) || ($field && $this->Priority = $this->owner->getField('Priority'))) {
|
||||
return ($this->Priority < 0) ? false : $this->Priority;
|
||||
if ($field) {
|
||||
$priority = $this->owner->getField('Priority');
|
||||
|
||||
return ($priority < 0) ? false : $priority;
|
||||
}
|
||||
|
||||
return GoogleSitemap::get_priority_for_class($this->owner->class);
|
||||
|
@ -103,10 +103,10 @@ class GoogleSitemap
|
||||
if (!self::is_registered($className)) {
|
||||
$className::add_extension(GoogleSitemapExtension::class);
|
||||
|
||||
self::$dataobjects[$className] = array(
|
||||
self::$dataobjects[$className] = [
|
||||
'frequency' => ($changeFreq) ? $changeFreq : 'monthly',
|
||||
'priority' => ($priority) ? $priority : '0.6'
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,16 +294,16 @@ class GoogleSitemapTest extends FunctionalTest
|
||||
|
||||
public function testUnpublishedPage()
|
||||
{
|
||||
if (!class_exists('SilverStripe\CMS\SiteTree')) {
|
||||
if (!class_exists('SilverStripe\CMS\Model\SiteTree')) {
|
||||
$this->markTestSkipped('Test skipped; CMS module required for testUnpublishedPage');
|
||||
}
|
||||
|
||||
$orphanedPage = new \SilverStripe\CMS\SiteTree();
|
||||
$orphanedPage = new \SilverStripe\CMS\Model\SiteTree();
|
||||
$orphanedPage->ParentID = 999999; // missing parent id
|
||||
$orphanedPage->write();
|
||||
$orphanedPage->publish("Stage", "Live");
|
||||
|
||||
$rootPage = new \SilverStripe\CMS\SiteTree();
|
||||
$rootPage = new \SilverStripe\CMS\Model\SiteTree();
|
||||
$rootPage->ParentID = 0;
|
||||
$rootPage->write();
|
||||
$rootPage->publish("Stage", "Live");
|
||||
|
Loading…
Reference in New Issue
Block a user