Source of file HandlerTest.php
Size: 1,678 Bytes - Last Modified: 2021-12-23T10:36:11+00:00
/var/www/docs.ssmods.com/process/src/tests/Handler/GraphQL/Mutation/HandlerTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | <?php namespace SilverStripe\Snapshots\Tests\Handler\GraphQL\Mutation; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Core\Injector\Injector; use SilverStripe\EventDispatcher\Symfony\Event; use SilverStripe\Snapshots\Handler\GraphQL\Mutation\Handler; use SilverStripe\Snapshots\Handler\PageContextProvider; use SilverStripe\Snapshots\Tests\Handler\GraphQL\FakePageContextProvider; use SilverStripe\Snapshots\Tests\SnapshotTestAbstract; class HandlerTest extends SnapshotTestAbstract { protected function setUp() { parent::setUp(); Injector::inst()->registerService( new FakePageContextProvider(), PageContextProvider::class ); } public function testHandlerDoesntFire() { $handler = Handler::create(); $this->mockSnapshot() ->expects($this->never()) ->method('createSnapshot'); $context = Event::create(null, []); $handler->fire($context); $context = Event::create('action', []); $handler->fire($context); } public function testHandlerDoesFire() { $handler = Handler::create(); $blockPage = SiteTree::create(); $blockPage->write(); Injector::inst()->get(PageContextProvider::class) ->setPage($blockPage); $this->mockSnapshot() ->expects($this->once()) ->method('createSnapshot') ->with($this->callback(function ($arg) use ($blockPage) { return $arg instanceof SiteTree && $arg->ID == $blockPage->ID; })); $context = Event::create('action', []); $handler->fire($context); } } |