Skip to content

Commit e29819e

Browse files
committed
build: allow symfony 4 or higher, raise minimum php version to 7.4
1 parent bf801d0 commit e29819e

15 files changed

Lines changed: 124 additions & 102 deletions

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ sudo: false
44

55
matrix:
66
include:
7-
- php: 7.1
7+
- php: 7.4
88
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=true
9-
- php: 7.2
9+
- php: 8.0
1010
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=false
1111
- php: nightly
1212
env: COLLECT_COVERAGE=false VALIDATE_CODING_STYLE=false

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,32 @@ Blocking Component
66
[![Build Status](https://img.shields.io/travis/brainbits/blocking/master.svg?style=flat-square)](https://travis-ci.org/brainbits/blocking)
77
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/brainbits/blocking.svg?style=flat-square)](https://scrutinizer-ci.com/g/brainbits/blocking/code-structure)
88
[![Quality Score](https://img.shields.io/scrutinizer/g/brainbits/blocking.svg?style=flat-square)](https://scrutinizer-ci.com/g/brainbits/blocking)
9-
[![Insight](https://img.shields.io/sensiolabs/i/bc35527c-11d8-45a1-a482-18d376cfe382.svg)](https://insight.sensiolabs.com/projects/bc35527c-11d8-45a1-a482-18d376cfe382)
109
[![Total Downloads](https://img.shields.io/packagist/dt/brainbits/blocking.svg?style=flat-square)](https://packagist.org/packages/brainbits/blocking)
1110

1211
The Blocking Component provides methods to manage content based blocking.
1312

14-
<?php
13+
```php
14+
<?php
1515

16-
use Brainbits\Blocking\Blocker;
17-
use Brainbits\Blocking\Identity\Identity;
18-
use Brainbits\Blocking\Owner\SymfonySessionOwnerFactory;
19-
use Brainbits\Blocking\Storage\FilesystemStorage;
20-
use Brainbits\Blocking\Validator\ExpiredValidator;
16+
use Brainbits\Blocking\Blocker;
17+
use Brainbits\Blocking\Identity\Identity;
18+
use Brainbits\Blocking\Owner\SymfonySessionOwnerFactory;
19+
use Brainbits\Blocking\Storage\FilesystemStorage;
20+
use Brainbits\Blocking\Validator\ExpiredValidator;
2121

22-
$storage = new FilesystemStorage('/where/to/store/blocks' /* path to directory on filesystem */);
23-
$ownerFactory = new SymfonySessionOwnerFactory($session /* symfony session */);
24-
$validator = new ExpiredValidator(300 /* block will expire after 300 seconds */);
22+
$storage = new FilesystemStorage('/where/to/store/blocks' /* path to directory on filesystem */);
23+
$ownerFactory = new SymfonySessionOwnerFactory($session /* symfony session */);
24+
$validator = new ExpiredValidator(300 /* block will expire after 300 seconds */);
2525

26-
$blocker = new Blocker($storage, $ownerFactory, $validator);
26+
$blocker = new Blocker($storage, $ownerFactory, $validator);
2727

28-
$identity = new Identity('my_content_123);
28+
$identity = new Identity('my_content_123');
2929

30-
$block = $blocker->block($identity);
31-
$result = $blocker->unblock($identity);
32-
$result = $blocker->isBlocked($identity);
33-
$block = $blocker->getBlock($identity);
30+
$block = $blocker->block($identity);
31+
$result = $blocker->unblock($identity);
32+
$result = $blocker->isBlocked($identity);
33+
$block = $blocker->getBlock($identity);
34+
```
3435

3536
Blocking Storage
3637
----------------

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.1"
14+
"php": "^7.4|^8.0"
1515
},
1616
"require-dev": {
1717
"mikey179/vfsstream": "^1.2",
18-
"phpunit/phpunit": "^6.0",
19-
"symfony/http-foundation": "^2.8|^3.0",
20-
"symfony/security-core": "^2.8|^3.0"
18+
"phpunit/phpunit": "^9.5",
19+
"symfony/http-foundation": ">=4.4",
20+
"symfony/security-core": ">=4.4",
21+
"phpspec/prophecy-phpunit": "^2.0"
2122
},
2223
"suggest": {
2324
"symfony/http-foundation": "If you want to use the SymfonySessionOwnerFactory",

phpunit.xml.dist

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
colors="true"
44
convertErrorsToExceptions="true"
55
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
syntaxCheck="true">
6+
convertWarningsToExceptions="true">
87
<testsuite name="blocking">
9-
<directory>Tests</directory>
8+
<directory suffix=".php">Tests</directory>
109
</testsuite>
11-
<filter>
12-
<whitelist>
13-
<directory suffix=".php">src</directory>
14-
</whitelist>
15-
</filter>
1610
</phpunit>

tests/BlockTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
use Brainbits\Blocking\Owner\OwnerInterface;
1717
use DateTimeImmutable;
1818
use PHPUnit\Framework\TestCase;
19+
use Prophecy\PhpUnit\ProphecyTrait;
1920
use Prophecy\Prophecy\ObjectProphecy;
2021

2122
/**
2223
* Block test
2324
*/
2425
class BlockTest extends TestCase
2526
{
27+
use ProphecyTrait;
28+
2629
/**
2730
* @var IdentityInterface|ObjectProphecy
2831
*/
@@ -33,7 +36,7 @@ class BlockTest extends TestCase
3336
*/
3437
private $owner;
3538

36-
protected function setUp()
39+
protected function setUp(): void
3740
{
3841
$this->identifier = $this->prophesize(IdentityInterface::class)->reveal();
3942

@@ -42,28 +45,28 @@ protected function setUp()
4245
->willReturn('dummyOwner');
4346
}
4447

45-
public function testConstruct()
48+
public function testConstruct(): void
4649
{
4750
$block = new Block($this->identifier, $this->owner->reveal(), new DateTimeImmutable());
4851

4952
$this->assertInstanceOf(Block::class, $block);
5053
}
5154

52-
public function testGetIdentifierReturnsCorrectValue()
55+
public function testGetIdentifierReturnsCorrectValue(): void
5356
{
5457
$block = new Block($this->identifier, $this->owner->reveal(), new DateTimeImmutable());
5558

5659
$this->assertSame($this->identifier, $block->getIdentity());
5760
}
5861

59-
public function testGetOwnerReturnsCorrectValue()
62+
public function testGetOwnerReturnsCorrectValue(): void
6063
{
6164
$block = new Block($this->identifier, $this->owner->reveal(), new DateTimeImmutable());
6265

6366
$this->assertSame($this->owner->reveal(), $block->getOwner());
6467
}
6568

66-
public function testIsOwnedByReturnsTrue()
69+
public function testIsOwnedByReturnsTrue(): void
6770
{
6871
$block = new Block($this->identifier, $this->owner->reveal(), new DateTimeImmutable());
6972

@@ -73,7 +76,7 @@ public function testIsOwnedByReturnsTrue()
7376
$this->assertTrue($block->isOwnedBy($this->owner->reveal()));
7477
}
7578

76-
public function testIsOwnedByReturnsFalse()
79+
public function testIsOwnedByReturnsFalse(): void
7780
{
7881
$block = new Block($this->identifier, $this->owner->reveal(), new DateTimeImmutable());
7982

@@ -87,7 +90,7 @@ public function testIsOwnedByReturnsFalse()
8790
$this->assertFalse($block->isOwnedBy($owner->reveal()));
8891
}
8992

90-
public function testGetCreatedAtReturnsCorrectValue()
93+
public function testGetCreatedAtReturnsCorrectValue(): void
9194
{
9295
$createdAt = new DateTimeImmutable();
9396

@@ -98,7 +101,7 @@ public function testGetCreatedAtReturnsCorrectValue()
98101
$this->assertSame($createdAt, $result);
99102
}
100103

101-
public function testGetUpdatedAtReturnsCreatedAtValueAfterInstanciation()
104+
public function testGetUpdatedAtReturnsCreatedAtValueAfterInstanciation(): void
102105
{
103106
$createdAt = new DateTimeImmutable();
104107

@@ -109,7 +112,7 @@ public function testGetUpdatedAtReturnsCreatedAtValueAfterInstanciation()
109112
$this->assertSame($createdAt, $result);
110113
}
111114

112-
public function testTouchUpdatesValue()
115+
public function testTouchUpdatesValue(): void
113116
{
114117
$createdAt = new DateTimeImmutable();
115118

tests/BlockerTest.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
use Brainbits\Blocking\Validator\ValidatorInterface;
2222
use PHPUnit\Framework\TestCase;
2323
use Prophecy\Argument;
24+
use Prophecy\PhpUnit\ProphecyTrait;
2425
use Prophecy\Prophecy\ObjectProphecy;
2526

2627
/**
2728
* Blocker test
2829
*/
2930
class BlockerTest extends TestCase
3031
{
32+
use ProphecyTrait;
33+
3134
/**
3235
* @var BlockInterface|ObjectProphecy
3336
*/
@@ -45,7 +48,7 @@ class BlockerTest extends TestCase
4548

4649
private $owner;
4750

48-
protected function setUp()
51+
protected function setUp(): void
4952
{
5053
$this->owner = new Owner('bar');
5154

@@ -62,7 +65,7 @@ protected function setUp()
6265
->willReturn(new Owner('baz'));
6366
}
6467

65-
public function testBlockReturnsBlockOnNonexistingBlock()
68+
public function testBlockReturnsBlockOnNonexistingBlock(): void
6669
{
6770
$storage = $this->createNonexistingStorage();
6871
$storage->write(Argument::type(BlockInterface::class))
@@ -78,7 +81,7 @@ public function testBlockReturnsBlockOnNonexistingBlock()
7881
$this->assertInstanceOf(BlockInterface::class, $result);
7982
}
8083

81-
public function testBlockReturnsBlockOnExistingAndInvalidBlock()
84+
public function testBlockReturnsBlockOnExistingAndInvalidBlock(): void
8285
{
8386
$storage = $this->createExistingStorage();
8487
$storage->remove(Argument::type(BlockInterface::class))
@@ -96,7 +99,7 @@ public function testBlockReturnsBlockOnExistingAndInvalidBlock()
9699
$this->assertInstanceOf(BlockInterface::class, $result);
97100
}
98101

99-
public function testBlockThrowsExceptionOnExistingAndValidAndNonOwnerBlock()
102+
public function testBlockThrowsExceptionOnExistingAndValidAndNonOwnerBlock(): void
100103
{
101104
$this->expectException(BlockFailedException::class);
102105

@@ -117,7 +120,7 @@ public function testBlockThrowsExceptionOnExistingAndValidAndNonOwnerBlock()
117120
$this->assertNull($result);
118121
}
119122

120-
public function testBlockUpdatesBlockOnExistingAndValidAndOwnedBlock()
123+
public function testBlockUpdatesBlockOnExistingAndValidAndOwnedBlock(): void
121124
{
122125
$storage = $this->createExistingStorage();
123126
$storage->touch($this->block)
@@ -136,7 +139,7 @@ public function testBlockUpdatesBlockOnExistingAndValidAndOwnedBlock()
136139
$this->assertInstanceOf(BlockInterface::class, $result);
137140
}
138141

139-
public function testUnblockReturnsNullOnExistingAndInvalidBlock()
142+
public function testUnblockReturnsNullOnExistingAndInvalidBlock(): void
140143
{
141144
$storage = $this->createExistingStorage();
142145
$storage->remove(Argument::type(BlockInterface::class))
@@ -152,7 +155,7 @@ public function testUnblockReturnsNullOnExistingAndInvalidBlock()
152155
$this->assertNull($result);
153156
}
154157

155-
public function testUnblockReturnsBlockOnExistingAndValidBlock()
158+
public function testUnblockReturnsBlockOnExistingAndValidBlock(): void
156159
{
157160
$storage = $this->createExistingStorage();
158161
$storage->remove(Argument::type(BlockInterface::class))
@@ -168,7 +171,7 @@ public function testUnblockReturnsBlockOnExistingAndValidBlock()
168171
$this->assertSame($this->block->reveal(), $result);
169172
}
170173

171-
public function testUnblockReturnsNullOnNonexistingBlock()
174+
public function testUnblockReturnsNullOnNonexistingBlock(): void
172175
{
173176
$storage = $this->createNonexistingStorage();
174177
$storage->remove()
@@ -184,7 +187,7 @@ public function testUnblockReturnsNullOnNonexistingBlock()
184187
$this->assertNull($result);
185188
}
186189

187-
public function testIsBlockedReturnsFalseOnExistingAndInvalidBlock()
190+
public function testIsBlockedReturnsFalseOnExistingAndInvalidBlock(): void
188191
{
189192
$storage = $this->createExistingStorage();
190193
$storage->remove(Argument::type(BlockInterface::class))
@@ -196,7 +199,7 @@ public function testIsBlockedReturnsFalseOnExistingAndInvalidBlock()
196199
$this->assertFalse($result);
197200
}
198201

199-
public function testIsBlockedReturnsTrueOnExistingAndValidBlock()
202+
public function testIsBlockedReturnsTrueOnExistingAndValidBlock(): void
200203
{
201204
$blocker = new Blocker(
202205
$this->createExistingStorage()->reveal(),
@@ -208,7 +211,7 @@ public function testIsBlockedReturnsTrueOnExistingAndValidBlock()
208211
$this->assertTrue($result);
209212
}
210213

211-
public function testIsBlockedReturnsFalseOnNonexistingBlock()
214+
public function testIsBlockedReturnsFalseOnNonexistingBlock(): void
212215
{
213216
$blocker = new Blocker(
214217
$this->createNonexistingStorage()->reveal(),
@@ -220,7 +223,7 @@ public function testIsBlockedReturnsFalseOnNonexistingBlock()
220223
$this->assertFalse($result);
221224
}
222225

223-
public function testGetBlockReturnsBlockOnExistingBlock()
226+
public function testGetBlockReturnsBlockOnExistingBlock(): void
224227
{
225228
$blocker = new Blocker(
226229
$this->createExistingStorage()->reveal(),

tests/Identifier/IdentifierTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
*/
2020
class IdentifierTest extends TestCase
2121
{
22-
public function testConstruct()
22+
public function testConstruct(): void
2323
{
2424
$identifier = new Identity('test_123');
2525

2626
$this->assertInstanceOf(Identity::class, $identifier);
2727
}
2828

29-
public function testEquals()
29+
public function testEquals(): void
3030
{
3131
$identifier1 = new Identity('foo');
3232
$identifier2 = new Identity('foo');
@@ -37,7 +37,7 @@ public function testEquals()
3737
$this->assertFalse($identifier2->equals($identifier3));
3838
}
3939

40-
public function testToString()
40+
public function testToString(): void
4141
{
4242
$identifier = new Identity('test_123');
4343

tests/Owner/OwnerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
*/
2020
class OwnerTest extends TestCase
2121
{
22-
public function testConstruct()
22+
public function testConstruct(): void
2323
{
2424
$owner = new Owner('test_123');
2525

2626
$this->assertInstanceOf(Owner::class, $owner);
2727
}
2828

29-
public function testEquals()
29+
public function testEquals(): void
3030
{
3131
$owner1 = new Owner('foo');
3232
$owner2 = new Owner('foo');
@@ -37,7 +37,7 @@ public function testEquals()
3737
$this->assertFalse($owner2->equals($owner3));
3838
}
3939

40-
public function testToString()
40+
public function testToString(): void
4141
{
4242
$owner = new Owner('test_123');
4343

tests/Owner/SymfonySessionOwnerFactoryTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@
1414
use Brainbits\Blocking\Owner\Owner;
1515
use Brainbits\Blocking\Owner\SymfonySessionOwnerFactory;
1616
use PHPUnit\Framework\TestCase;
17+
use Prophecy\PhpUnit\ProphecyTrait;
1718
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1819

1920
/**
2021
* Symfony session owner test
2122
*/
2223
class SymfonySessionOwnerFactoryTest extends TestCase
2324
{
24-
public function testToString()
25+
use ProphecyTrait;
26+
27+
public function testToString(): void
2528
{
2629
$factory = new SymfonySessionOwnerFactory($this->createSession('foo'));
2730
$owner = $factory->createOwner();
2831

2932
$this->assertEquals($owner, new Owner('foo'));
3033
}
3134

35+
/**
36+
* @return SessionInterface|ObjectProphecy
37+
*/
3238
private function createSession($sessionId)
3339
{
3440
$session = $this->prophesize(SessionInterface::class);

0 commit comments

Comments
 (0)