Skip to content

Commit ba1ebda

Browse files
committed
Fix more deprecations in tests, use attributes for phpunit. Enable one commented test
1 parent 46ff8a9 commit ba1ebda

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

tests/TestCase/Model/Table/IncidentsTableTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Model\Table\IncidentsTable;
66
use Cake\ORM\TableRegistry;
77
use Cake\TestSuite\TestCase;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89
use ReflectionMethod;
910

1011
use function count;
@@ -492,16 +493,16 @@ public function testCreateIncidentFromBugReport(): void
492493
}
493494

494495
/**
495-
* @dataProvider versionsStripping
496496
* @param string $version The version
497497
* @param string $expected The expected version
498498
*/
499+
#[DataProvider('versionsStripping')]
499500
public function testStripversion(string $version, string $expected): void
500501
{
501502
$this->assertEquals($expected, IncidentsTable::getStrippedPmaVersion($version));
502503
}
503504

504-
public function versionsStripping(): array
505+
public static function versionsStripping(): array
505506
{
506507
return [
507508
[

tests/TestCase/Model/Table/NotificationsTableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace App\Test\TestCase\Model\Table;
44

5-
use App\Model\Table\NotificationTable;
5+
use App\Model\Table\NotificationsTable;
66
use Cake\ORM\TableRegistry;
77
use Cake\TestSuite\TestCase;
88

@@ -13,7 +13,7 @@
1313
*/
1414
class NotificationsTableTest extends TestCase
1515
{
16-
protected NotificationTable $Notification;
16+
protected NotificationsTable $Notifications;
1717

1818
/**
1919
* Fixtures.

tests/TestCase/Model/Table/ReportsTableTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ public function testGetIncidents(): void
4343
//$this->assertEquals(count($incidents), 2);
4444
}
4545

46-
//TODO: will do after related to fix
47-
//public function testGetRelatedReports() {
48-
// $this->Reports->id = 2;
49-
// $reports = $this->Reports->getRelatedReports();
50-
// $this->assertEquals(count($reports), 0);
51-
//
52-
// $this->Report->read(null, 4);
53-
// $reports = $this->Report->getRelatedReports();
54-
// $this->assertEquals(count($reports), 1);
55-
//}
46+
public function testGetRelatedReports(): void
47+
{
48+
$this->Reports->id = 2;
49+
$reports = $this->Reports->getRelatedReports()->all();
50+
$this->assertEquals(count($reports), 0);
51+
52+
$this->markTestIncomplete('Does not work anymore');
53+
$this->Reports->read(null, 4);
54+
$reports = $this->Reports->getRelatedReports()->all();
55+
$this->assertEquals(count($reports), 1);
56+
}
5657

5758
/**
5859
* Test for getIncidentsWithDescription

tests/TestCase/View/Helper/ReportsHelperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace App\Test\TestCase\View\Helper;
44

5-
use App\Model\Table\ReportsTable;
65
use App\View\Helper\ReportsHelper;
76
use Cake\TestSuite\TestCase;
87
use Cake\View\View;
8+
use PHPUnit\Framework\Attributes\DataProvider;
99

1010
class ReportsHelperTest extends TestCase
1111
{
12-
protected ReportsTable $Reports;
12+
protected ReportsHelper $Reports;
1313

1414
public function setUp(): void
1515
{
@@ -23,7 +23,7 @@ public function setUp(): void
2323
*
2424
* @return array array data for testLinkToReport
2525
*/
26-
public function providerForTestLinkToReport(): array
26+
public static function providerForTestLinkToReport(): array
2727
{
2828
return [
2929
[
@@ -60,10 +60,10 @@ public function providerForTestLinkToReport(): array
6060
}
6161

6262
/**
63-
* @dataProvider providerForTestLinkToReport
6463
* @param array $report The report
6564
* @param string $expected The expected
6665
*/
66+
#[DataProvider('providerForTestLinkToReport')]
6767
public function testLinkToReport(array $report, string $expected): void
6868
{
6969
$link = $this->Reports->linkToReport($report);
@@ -79,7 +79,7 @@ public function testLinkToReport(array $report, string $expected): void
7979
*
8080
* @return array array data to testCreateReportsLinks
8181
*/
82-
public function providerForTestCreateReportsLinks(): array
82+
public static function providerForTestCreateReportsLinks(): array
8383
{
8484
return [
8585
[
@@ -116,10 +116,10 @@ public function providerForTestCreateReportsLinks(): array
116116
}
117117

118118
/**
119-
* @dataProvider providerForTestCreateReportsLinks
120119
* @param array $reports The reports
121120
* @param string $expected The expected reports
122121
*/
122+
#[DataProvider('providerForTestCreateReportsLinks')]
123123
public function testCreateReportsLinks(array $reports, string $expected): void
124124
{
125125
$links_str = $this->Reports->createReportsLinks($reports);

0 commit comments

Comments
 (0)