Issues (25)

tests/CalculatorTest.php (1 issue)

1
<?php
2
3
namespace SilverStripe\ModuleRatings\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use SilverStripe\ModuleRatings\Calculator;
7
8
class CalculatorTest extends TestCase
9
{
10
    public function testGetInstance()
11
    {
12
        $instanceA = Calculator::getInstance();
13
        $instanceB = Calculator::getInstance();
14
15
        $this->assertSame($instanceA, $instanceB);
16
    }
17
18
    public function testCalculate()
19
    {
20
        $mock = $this->getMockBuilder(Calculator::class)
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
        $mock = /** @scrutinizer ignore-deprecated */ $this->getMockBuilder(Calculator::class)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
21
            ->setMethods(['getMaxPoints'])
22
            ->getMock();
23
24
        $mock->expects($this->exactly(3))->method('getMaxPoints')->willReturn(140);
25
26
        $this->assertEquals(70, $mock->calculate(98));
27
        $this->assertEquals(0, $mock->calculate(0));
28
        $this->assertEquals(100, $mock->calculate(139));
29
    }
30
}
31