Skip to content

Commit 5eb24e7

Browse files
aszenzhomersimpsons
authored andcommitted
deps: Upgrade pkgs
+ Upgrade phpunit and fix tests + Fix passing null to strpos triggering warning on new php + Raise doctrine/cache to v1.4.1 since void cache was not in 1.4
1 parent 0ccb1a2 commit 5eb24e7

File tree

7 files changed

+34
-42
lines changed

7 files changed

+34
-42
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
composer.lock
22
/vendor/
3-
/build/
3+
/build/
4+
.phpunit.result.cache

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
}
1515
},
1616
"require": {
17+
"php": "^7.4 || ^8.0",
1718
"clue/graph": "~0.9.0",
1819
"doctrine/dbal": "^3.0",
19-
"doctrine/cache": "^1.4",
20+
"doctrine/cache": "^1.4.1",
2021
"graphp/algorithms": "~0.8.0"
2122
},
2223
"require-dev": {
23-
"phpunit/phpunit": "^4.8.36",
24-
"satooshi/php-coveralls": "^1.0"
24+
"phpunit/phpunit": "^9.6.16",
25+
"php-coveralls/php-coveralls": "^2.7.0"
2526
}
2627
}

phpunit.xml.dist

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,20 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="tests/bootstrap.php"
1312
>
1413
<testsuites>
1514
<testsuite name="Test Suite">
1615
<directory>./tests/</directory>
1716
</testsuite>
1817
</testsuites>
19-
<filter>
20-
<whitelist processUncoveredFilesFromWhitelist="true">
18+
<coverage>
19+
<include>
2120
<directory suffix=".php">src</directory>
22-
</whitelist>
23-
</filter>
24-
25-
<logging>
26-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
27-
<log type="coverage-clover" target="build/logs/clover.xml"/>
28-
</logging>
21+
</include>
22+
<report>
23+
<html outputDirectory="build/coverage" />
24+
<clover outputFile="build/logs/clover.xml"/>
25+
</report>
26+
</coverage>
2927
</phpunit>

src/MultiDijkstra.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static function getCheapestPathFromPredecesArray(Vertex $startVertex, Ver
146146
if (count($predecessorEdges) > 1) {
147147
throw new MultiDijkstraAmbiguityException("There are many possible shortest paths to link vertex '".$startVertex->getId()."' to '".$endVertex->getId()."'");
148148
}
149-
/* @var $edge \Fhaculty\Graph\Edge\Base */
149+
/** @var $edge \Fhaculty\Graph\Edge\Base */
150150
$edge = $predecessorEdges[0];
151151
$edges[] = $edge;
152152
if ($currentVertex === $edge->getVerticesStart()->getVertexFirst()) {

src/SchemaAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function isJunctionTable(Table $table, $ignoreReferencedTables = false)
169169

170170
// Let's check that the primary key is autoincremented
171171
$pkColumn = $table->getColumn($pkColumns[0]);
172-
if (!$pkColumn->getAutoincrement() && strpos($pkColumn->getComment(), '@Autoincrement') === false) {
172+
if (!$pkColumn->getAutoincrement() && strpos($pkColumn->getComment() ?? '', '@Autoincrement') === false) {
173173
return false;
174174
}
175175
}

tests/MultiDijkstraTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
use Fhaculty\Graph\Graph;
66
use Fhaculty\Graph\Vertex;
77
use Fhaculty\Graph\Edge;
8+
use Fhaculty\Graph\Exception\UnexpectedValueException;
9+
use PHPUnit\Framework\TestCase;
810

9-
class MultiDijkstraTest extends \PHPUnit_Framework_TestCase
11+
class MultiDijkstraTest extends TestCase
1012
{
1113
public function testDijkstra()
1214
{
@@ -47,9 +49,6 @@ public function testDijkstra()
4749
$this->assertTrue($this->hasVertex($edges[2], $h));
4850
}
4951

50-
/**
51-
* @expectedException \Mouf\Database\SchemaAnalyzer\MultiDijkstraAmbiguityException
52-
*/
5352
public function testDijkstraAmbiguity()
5453
{
5554
$graph = new Graph();
@@ -66,12 +65,10 @@ public function testDijkstraAmbiguity()
6665

6766
$predecessors = MultiDijkstra::findShortestPaths($a, $d);
6867

68+
$this->expectException(MultiDijkstraAmbiguityException::class);
6969
MultiDijkstra::getCheapestPathFromPredecesArray($a, $d, $predecessors);
7070
}
7171

72-
/**
73-
* @expectedException \Mouf\Database\SchemaAnalyzer\MultiDijkstraNoPathException
74-
*/
7572
public function testDijkstraNoPath()
7673
{
7774
$graph = new Graph();
@@ -84,12 +81,10 @@ public function testDijkstraNoPath()
8481
$a->createEdge($b)->setWeight(12);
8582
$a->createEdge($c)->setWeight(42);
8683

84+
$this->expectException(MultiDijkstraNoPathException::class);
8785
MultiDijkstra::findShortestPaths($a, $d);
8886
}
8987

90-
/**
91-
* @expectedException \Fhaculty\Graph\Exception\UnexpectedValueException
92-
*/
9388
public function testDijkstraNegativeWeight()
9489
{
9590
$graph = new Graph();
@@ -99,6 +94,7 @@ public function testDijkstraNegativeWeight()
9994

10095
$a->createEdge($b)->setWeight(-12);
10196

97+
$this->expectException(UnexpectedValueException::class);
10298
MultiDijkstra::findShortestPaths($a, $b);
10399
}
104100

tests/SchemaAnalyzerTest.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
use Doctrine\Common\Cache\ArrayCache;
66
use Doctrine\DBAL\Schema\Schema;
7+
use PHPUnit\Framework\TestCase;
78

8-
class SchemaAnalyzerTest extends \PHPUnit_Framework_TestCase
9+
class SchemaAnalyzerTest extends TestCase
910
{
1011
/**
1112
* Returns a base schema with a role and a right table.
@@ -294,12 +295,10 @@ public function testShortestPathInLine()
294295
$this->assertEquals('role', $fks[0]->getForeignTableName());
295296
}
296297

297-
/**
298-
* @expectedException \Mouf\Database\SchemaAnalyzer\SchemaAnalyzerException
299-
*/
300298
public function testWrongConstructor()
301299
{
302300
$schema = $this->getBaseSchema();
301+
$this->expectException(SchemaAnalyzerException::class);
303302
new SchemaAnalyzer(new StubSchemaManager($schema), new ArrayCache());
304303
}
305304

@@ -347,8 +346,8 @@ public function testAmbiguityException()
347346
try {
348347
$schemaAnalyzer->getShortestPath('role', 'right');
349348
} catch (ShortestPathAmbiguityException $e) {
350-
$this->assertContains('role <=(role_right)=> right', $e->getMessage());
351-
$this->assertContains('role <=(role_right2)=> right', $e->getMessage());
349+
$this->assertStringContainsString('role <=(role_right)=> right', $e->getMessage());
350+
$this->assertStringContainsString('role <=(role_right2)=> right', $e->getMessage());
352351
$exceptionTriggered = true;
353352
}
354353
$this->assertTrue($exceptionTriggered);
@@ -357,8 +356,8 @@ public function testAmbiguityException()
357356
try {
358357
$schemaAnalyzer->getShortestPath('right', 'role');
359358
} catch (ShortestPathAmbiguityException $e) {
360-
$this->assertContains('right <=(role_right)=> role', $e->getMessage());
361-
$this->assertContains('right <=(role_right2)=> role', $e->getMessage());
359+
$this->assertStringContainsString('right <=(role_right)=> role', $e->getMessage());
360+
$this->assertStringContainsString('right <=(role_right2)=> role', $e->getMessage());
362361
$exceptionTriggered = true;
363362
}
364363
$this->assertTrue($exceptionTriggered);
@@ -380,8 +379,8 @@ public function testAmbiguityExceptionWithNoJointure()
380379
try {
381380
$schemaAnalyzer->getShortestPath('role', 'right');
382381
} catch (ShortestPathAmbiguityException $e) {
383-
$this->assertContains('role <--(role_id)-- right', $e->getMessage());
384-
$this->assertContains('role <--(role_id2)-- right', $e->getMessage());
382+
$this->assertStringContainsString('role <--(role_id)-- right', $e->getMessage());
383+
$this->assertStringContainsString('role <--(role_id2)-- right', $e->getMessage());
385384
$exceptionTriggered = true;
386385
}
387386
$this->assertTrue($exceptionTriggered);
@@ -390,8 +389,8 @@ public function testAmbiguityExceptionWithNoJointure()
390389
try {
391390
$schemaAnalyzer->getShortestPath('right', 'role');
392391
} catch (ShortestPathAmbiguityException $e) {
393-
$this->assertContains('right --(role_id)--> role', $e->getMessage());
394-
$this->assertContains('right --(role_id2)--> role', $e->getMessage());
392+
$this->assertStringContainsString('right --(role_id)--> role', $e->getMessage());
393+
$this->assertStringContainsString('right --(role_id2)--> role', $e->getMessage());
395394
$exceptionTriggered = true;
396395
}
397396
$this->assertTrue($exceptionTriggered);
@@ -550,15 +549,12 @@ public function testChainedJunctionTables()
550549
$this->assertEquals('role_users', $fks[3]->getName());
551550
}
552551

553-
/**
554-
* @expectedException \Mouf\Database\SchemaAnalyzer\SchemaAnalyzerTableNotFoundException
555-
* @expectedExceptionMessage Could not find table 'rights'. Did you mean 'right'?
556-
*/
557552
public function testWringTableName()
558553
{
559554
$schemaManager = $this->getCompleteSchemaManager();
560555

561556
$schemaAnalyzer = new SchemaAnalyzer($schemaManager);
557+
$this->expectException(SchemaAnalyzerTableNotFoundException::class, "Could not find table 'rights'. Did you mean 'right'?");
562558
$junctionTables = $schemaAnalyzer->getShortestPath('role', 'rights');
563559
}
564560
}

0 commit comments

Comments
 (0)