MCPcopy Create free account
hub / github.com/Rello/analytics / testValidate

Method testValidate

tests/Service/ThresholdServiceTest.php:18–62  ·  view source on GitHub ↗

* @dataProvider validationData */

(array $thresholds, array $dataset, $dimension1, $dimension2, $value, $expectedNotification)

Source from the content-addressed store, hash-verified

16 * @dataProvider validationData
17 */
18 public function testValidate(array $thresholds, array $dataset, $dimension1, $dimension2, $value, $expectedNotification)
19 {
20 $thresholdMapper = $this->createMock(ThresholdMapper::class);
21 $thresholdMapper->method('getSevOneThresholdsByReport')->willReturn($thresholds);
22
23 $reportMapper = $this->createMock(ReportMapper::class);
24 $reportMapper->method('read')->willReturn($dataset);
25
26 $notification = $this->createMock(NotificationManager::class);
27 if ($expectedNotification) {
28 $notification->expects($this->once())->method('triggerNotification');
29 } else {
30 $notification->expects($this->never())->method('triggerNotification');
31 }
32
33 $datasetMapper = $this->createMock(\OCA\Analytics\Db\DatasetMapper::class);
34 $dateFormatter = $this->createMock(IDateTimeFormatter::class);
35
36 $variableService = new VariableService(
37 new NullLogger(),
38 $datasetMapper,
39 $dateFormatter
40 );
41
42 $service = new ThresholdService(
43 new NullLogger(),
44 $thresholdMapper,
45 $notification,
46 $reportMapper,
47 $variableService,
48 new FakeL10N()
49 );
50
51 // Call read to trigger variable replacement logic
52 //$this->assertSame($thresholds, $service->read(1));
53
54 $result = $service->validate($dataset['id'], $dimension1, $dimension2, $value);
55
56 // Assert whatever return value or side effects you need
57 if ($expectedNotification) {
58 $this->assertSame('Threshold value met', $result);
59 } else {
60 $this->assertNull($result);
61 }
62 }
63
64 public function validationData()
65 {

Callers

nothing calls this directly

Calls 1

validateMethod · 0.45

Tested by

no test coverage detected