Skip to content

Commit 8d75952

Browse files
committed
Cover change with Unit Tests
1 parent a08d497 commit 8d75952

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Theme\Test\Unit\Plugin;
9+
10+
use Magento\Framework\Data\Collection;
11+
use Magento\Theme\Plugin\Data\Collection as CollectionPlugin;
12+
use PHPUnit\Framework\MockObject\MockObject;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class CollectionTest extends TestCase
16+
{
17+
/** @var MockObject|Collection */
18+
private $dataCollectionMock;
19+
20+
protected function setUp(): void
21+
{
22+
$this->dataCollectionMock = $this->getMockBuilder(Collection::class)
23+
->disableOriginalConstructor()
24+
->onlyMethods(['getLastPageNumber'])
25+
->getMock();
26+
}
27+
28+
public function testCurrentPageIsNotOverriddenIfFirstPage()
29+
{
30+
// Given
31+
$currentPagePlugin = new CollectionPlugin();
32+
33+
// Expects
34+
$this->dataCollectionMock->expects($this->never())
35+
->method('getLastPageNumber');
36+
37+
// When
38+
$currentPagePlugin->afterGetCurPage($this->dataCollectionMock, 1);
39+
}
40+
41+
public function testCurrentPageIsOverriddenIfNotAFirstPage()
42+
{
43+
// Given
44+
$currentPagePlugin = new CollectionPlugin();
45+
46+
// Expects
47+
$this->dataCollectionMock->expects($this->once())
48+
->method('getLastPageNumber');
49+
50+
// When
51+
$currentPagePlugin->afterGetCurPage($this->dataCollectionMock, 2);
52+
}
53+
}

0 commit comments

Comments
 (0)