Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEP Use PHPUnit 11 #256

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions tests/php/ContentReviewBaseTest.php

This file was deleted.

3 changes: 2 additions & 1 deletion tests/php/ContentReviewCMSPageEditControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Dev\FunctionalTest;

class ContentReviewCMSPageEditControllerTest extends ContentReviewBaseTest
class ContentReviewCMSPageEditControllerTest extends FunctionalTest
{
/**
* @var string
Expand Down
8 changes: 4 additions & 4 deletions tests/php/Extensions/ContentReviewCMSExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ContentReviewCMSExtensionTest extends SapphireTest
public function testReviewContentForm()
{
$mock = $this->getMockBuilder(ContentReviewCMSExtension::class)
->setMethods(['getReviewContentForm'])
->onlyMethods(['getReviewContentForm'])
->getMock();

$mock->expects($this->once())->method('getReviewContentForm')->with(123)->willReturn(true);
Expand All @@ -45,7 +45,7 @@ public function testGetReviewContentFormThrowsExceptionWhenObjectCannotBeReviewe
$this->logOut();

$mock = $this->getMockBuilder(ContentReviewCMSExtension::class)
->setMethods(['findRecord'])
->onlyMethods(['findRecord'])
->getMock();

$mock->setOwner(new Controller);
Expand All @@ -62,7 +62,7 @@ public function testGetReviewContentFormThrowsExceptionWhenObjectCannotBeReviewe
public function testSaveReviewCallsHandler()
{
$mock = $this->getMockBuilder(ContentReviewCMSExtension::class)
->setMethods(['findRecord', 'getReviewContentHandler'])
->onlyMethods(['findRecord', 'getReviewContentHandler'])
->getMock();

$mock->setOwner(new Controller);
Expand All @@ -71,7 +71,7 @@ public function testSaveReviewCallsHandler()
$mock->expects($this->once())->method('findRecord')->willReturn($mockPage);

$mockHandler = $this->getMockBuilder(ReviewContentHandler::class)
->setMethods(['submitReview'])
->onlyMethods(['submitReview'])
->getMock();

$mockHandler->expects($this->once())
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Forms/ReviewContentHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testAddReviewNoteCalledWhenSubmittingReview()

$mock = $this->getMockBuilder(ReviewContentHandler::class)
->setConstructorArgs([$controller])
->setMethods(['canSubmitReview'])
->onlyMethods(['canSubmitReview'])
->getMock();

$mock->expects($this->exactly(3))->method('canSubmitReview')->willReturn(true);
Expand Down
18 changes: 9 additions & 9 deletions tests/php/SiteTreeContentReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\ContentReview\Tests\SiteTreeContentReviewTestPage;

class SiteTreeContentReviewTest extends ContentReviewBaseTest
class SiteTreeContentReviewTest extends FunctionalTest
{
protected $usesTransactions = false;

protected static $extra_dataobjects = [
SiteTreeContentReviewTestPage::class,
];

/**
* @var string
*/
Expand Down Expand Up @@ -372,14 +378,8 @@ public function testPermissionCheckByOnDataObject()
{
$reviewer = $this->objFromFixture(Member::class, 'editor');

// Mock Page class with canReviewContent method to return true on first call and false on second call
$mock = $this->getMockBuilder(Page::class)
->setMethods(['canReviewContent', 'NextReviewDate', 'OwnerUsers'])
->getMock();
$mock->expects($this->exactly(2))->method('canReviewContent')->willReturnOnConsecutiveCalls(false, true);
$mock->method('NextReviewDate')->willReturn('2020-02-20 12:00:00');
$mock->method('OwnerUsers')->willReturn(ArrayList::create([$reviewer]));
$mock->ContentReviewType = 'Custom';
$mock = new SiteTreeContentReviewTestPage();
$mock->setReviewer($reviewer);

/** @var SiteTreeContentReview $extension */
$extension = Injector::inst()->get(SiteTreeContentReview::class);
Expand Down
41 changes: 41 additions & 0 deletions tests/php/SiteTreeContentReviewTestPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace SilverStripe\ContentReview\Tests;

use Page;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\ArrayList;

/**
* Mock Page class with canReviewContent method to return false on first call
* and true on second call
*/
class SiteTreeContentReviewTestPage extends Page implements TestOnly
{
public $ContentReviewType = 'Custom';

private $i = 0;

private $reviewer;

public function setReviewer($reviewer)
{
$this->reviewer = $reviewer;
}

public function canReviewContent()
{
$this->i++;
return $this->i === 1 ? false : true;
}

public function NextReviewDate()
{
return '2020-02-20 12:00:00';
}

public function OwnerUsers()
{
return ArrayList::create([$this->reviewer]);
}
}
Loading