Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 7b94efe

Browse files
committed
Merge branch 'feature/50' into develop
Close #50 Close #51
2 parents 1d465d9 + 1de875d commit 7b94efe

11 files changed

+403
-192
lines changed

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,23 @@ matrix:
2222
env:
2323
- EXECUTE_CS_CHECK=true
2424
- EXECUTE_HOSTNAME_CHECK=true
25+
- php: 5.5
26+
env:
27+
- SERVICE_MANAGER_VERSION="^2.7.5"
2528
- php: 5.6
2629
env:
2730
- EXECUTE_TEST_COVERALLS=true
31+
- php: 5.6
32+
env:
33+
- SERVICE_MANAGER_VERSION="^2.7.5"
2834
- php: 7
35+
- php: 7
36+
env:
37+
- SERVICE_MANAGER_VERSION="^2.7.5"
2938
- php: hhvm
39+
- php: hhvm
40+
env:
41+
- SERVICE_MANAGER_VERSION="^2.7.5"
3042
allow_failures:
3143
- php: hhvm
3244

@@ -38,6 +50,9 @@ before_install:
3850
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
3951
- composer self-update
4052
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
53+
- if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi
54+
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi
55+
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer remove --dev --no-update zendframework/zend-db zendframework/zend-session ; fi
4156

4257
install:
4358
- travis_retry composer install --no-interaction --ignore-platform-reqs

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ All notable changes to this project will be documented in this file, in reverse
2929

3030
### Fixed
3131

32-
- [#49](https://github.com/zendframework/zend-validator/pull/49) updates the
33-
code to work with the upcoming zend-servicemanager v3.
32+
- [#45](https://github.com/zendframework/zend-validator/pull/45) fixes aliases
33+
mapping the deprecated `Float` and `Int` validators to their `Is*` counterparts.
34+
- [#49](https://github.com/zendframework/zend-validator/pull/49)
35+
[#50](https://github.com/zendframework/zend-validator/pull/50), and
36+
[#51](https://github.com/zendframework/zend-validator/pull/51) update the
37+
code to be forwards-compatible with zend-servicemanager and zend-stdlib v3.
38+
- [#56](https://github.com/zendframework/zend-validator/pull/56) fixes the regex
39+
in the `Ip` validator to escape `.` characters used as IP delimiters.
3440

3541
## 2.5.5 - TBD
3642

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@
1414
},
1515
"require": {
1616
"php": "^5.5 || ^7.0",
17-
"zendframework/zend-stdlib": "dev-develop as 2.8.0",
17+
"zendframework/zend-stdlib": "^2.7 || ^3.0",
1818
"container-interop/container-interop": "^1.1"
1919
},
2020
"require-dev": {
21-
"zendframework/zend-cache": "dev-develop as 2.6.0",
22-
"zendframework/zend-config": "dev-develop as 2.6.0",
23-
"zendframework/zend-db": "dev-develop as 2.7.0",
24-
"zendframework/zend-filter": "dev-develop as 2.6.0",
25-
"zendframework/zend-http": "~2.5",
26-
"zendframework/zend-i18n": "dev-develop as 2.6.0",
27-
"zendframework/zend-math": "dev-develop as 2.6.0",
28-
"zendframework/zend-servicemanager": "dev-develop as 2.7.0",
29-
"zendframework/zend-session": "dev-develop as 2.6.0",
30-
"zendframework/zend-uri": "~2.5",
21+
"zendframework/zend-cache": "^2.6.1",
22+
"zendframework/zend-config": "^2.6",
23+
"zendframework/zend-db": "^2.5",
24+
"zendframework/zend-filter": "^2.6",
25+
"zendframework/zend-http": "^2.5.4",
26+
"zendframework/zend-i18n": "^2.6",
27+
"zendframework/zend-math": "^2.6",
28+
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
29+
"zendframework/zend-session": "^2.5",
30+
"zendframework/zend-uri": "^2.5",
3131
"fabpot/php-cs-fixer": "1.7.*",
32-
"phpunit/PHPUnit": "~4.0"
32+
"phpunit/PHPUnit": "^4.0"
3333
},
3434
"suggest": {
3535
"zendframework/zend-db": "Zend\\Db component",

src/StaticValidator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ public static function setPluginManager(ValidatorPluginManager $plugins = null)
2828
{
2929
// Don't share by default to allow different arguments on subsequent calls
3030
if ($plugins instanceof ValidatorPluginManager) {
31-
$plugins->configure(['shared_by_default' => false]);
31+
// Vary how the share by default flag is set based on zend-servicemanager version
32+
if (method_exists($plugins, 'configure')) {
33+
$plugins->configure(['shared_by_default' => false]);
34+
} else {
35+
$plugins->setShareByDefault(false);
36+
}
3237
}
3338
static::$plugins = $plugins;
3439
}

src/ValidatorPluginManager.php

Lines changed: 148 additions & 130 deletions
Large diffs are not rendered by default.

test/CsrfTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ class CsrfTest extends \PHPUnit_Framework_TestCase
2828

2929
public function setUp()
3030
{
31+
if (! class_exists(Container::class)) {
32+
$this->markTestSkipped(
33+
'Skipping zend-session-related tests until the component is updated '
34+
. ' to zend-servicemanager/zend-eventmanager v3'
35+
);
36+
}
37+
3138
// Setup session handling
3239
$_SESSION = [];
3340
$sessionConfig = new StandardConfig([
@@ -42,6 +49,10 @@ public function setUp()
4249

4350
public function tearDown()
4451
{
52+
if (! class_exists(Container::class)) {
53+
return;
54+
}
55+
4556
$_SESSION = [];
4657
Container::setDefaultManager(null);
4758
}

test/Db/AbstractDbTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class AbstractDbTest extends \PHPUnit_Framework_TestCase
2424

2525
public function setUp()
2626
{
27+
if (! class_exists('Zend\Db\Adapter\Adapter')) {
28+
$this->markTestSkipped(
29+
'Skipping zend-db-related tests until that component is updated '
30+
. 'to zend-servicemanager/zend-eventmanager v3'
31+
);
32+
}
33+
2734
$this->validator = new ConcreteDbValidator([
2835
'table' => 'table',
2936
'field' => 'field',

test/Db/NoRecordExistsTest.php

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
*/
1919
class NoRecordExistsTest extends \PHPUnit_Framework_TestCase
2020
{
21+
public function setUp()
22+
{
23+
if (! class_exists('Zend\Db\Adapter\Adapter')) {
24+
$this->markTestSkipped(
25+
'Skipping zend-db-related tests until that component is updated '
26+
. 'to zend-servicemanager/zend-eventmanager v3'
27+
);
28+
}
29+
}
30+
2131
/**
2232
* Return a Mock object for a Db result with rows
2333
*
@@ -121,8 +131,12 @@ public function testBasicFindsNoRecord()
121131
*/
122132
public function testExcludeWithArray()
123133
{
124-
$validator = new NoRecordExists('users', 'field1', ['field' => 'id', 'value' => 1],
125-
$this->getMockHasResult());
134+
$validator = new NoRecordExists(
135+
'users',
136+
'field1',
137+
['field' => 'id', 'value' => 1],
138+
$this->getMockHasResult()
139+
);
126140
$this->assertFalse($validator->isValid('value3'));
127141
}
128142

@@ -134,8 +148,12 @@ public function testExcludeWithArray()
134148
*/
135149
public function testExcludeWithArrayNoRecord()
136150
{
137-
$validator = new NoRecordExists('users', 'field1', ['field' => 'id', 'value' => 1],
138-
$this->getMockNoResult());
151+
$validator = new NoRecordExists(
152+
'users',
153+
'field1',
154+
['field' => 'id', 'value' => 1],
155+
$this->getMockNoResult()
156+
);
139157
$this->assertTrue($validator->isValid('nosuchvalue'));
140158
}
141159

@@ -172,8 +190,10 @@ public function testExcludeWithStringNoRecord()
172190
public function testThrowsExceptionWithNoAdapter()
173191
{
174192
$validator = new NoRecordExists('users', 'field1', 'id != 1');
175-
$this->setExpectedException('Zend\Validator\Exception\RuntimeException',
176-
'No database adapter present');
193+
$this->setExpectedException(
194+
'Zend\Validator\Exception\RuntimeException',
195+
'No database adapter present'
196+
);
177197
$validator->isValid('nosuchvalue');
178198
}
179199

@@ -184,8 +204,10 @@ public function testThrowsExceptionWithNoAdapter()
184204
*/
185205
public function testWithSchema()
186206
{
187-
$validator = new NoRecordExists(['table' => 'users', 'schema' => 'my'],
188-
'field1', null, $this->getMockHasResult());
207+
$validator = new NoRecordExists([
208+
'table' => 'users',
209+
'schema' => 'my'
210+
], 'field1', null, $this->getMockHasResult());
189211
$this->assertFalse($validator->isValid('value1'));
190212
}
191213

@@ -196,15 +218,20 @@ public function testWithSchema()
196218
*/
197219
public function testWithSchemaNoResult()
198220
{
199-
$validator = new NoRecordExists(['table' => 'users', 'schema' => 'my'],
200-
'field1', null, $this->getMockNoResult());
221+
$validator = new NoRecordExists([
222+
'table' => 'users',
223+
'schema' => 'my'
224+
], 'field1', null, $this->getMockNoResult());
201225
$this->assertTrue($validator->isValid('value1'));
202226
}
203227

204228
public function testEqualsMessageTemplates()
205229
{
206230
$validator = new NoRecordExists('users', 'field1');
207-
$this->assertAttributeEquals($validator->getOption('messageTemplates'),
208-
'messageTemplates', $validator);
231+
$this->assertAttributeEquals(
232+
$validator->getOption('messageTemplates'),
233+
'messageTemplates',
234+
$validator
235+
);
209236
}
210237
}

test/Db/RecordExistsTest.php

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
*/
2222
class RecordExistsTest extends \PHPUnit_Framework_TestCase
2323
{
24+
public function setUp()
25+
{
26+
if (! class_exists(Adapter::class)) {
27+
$this->markTestSkipped(
28+
'Skipping zend-db-related tests until that component is updated '
29+
. 'to zend-servicemanager/zend-eventmanager v3'
30+
);
31+
}
32+
}
33+
2434
/**
2535
* Return a Mock object for a Db result with rows
2636
*
@@ -102,9 +112,11 @@ protected function getMockNoResult()
102112
*/
103113
public function testBasicFindsRecord()
104114
{
105-
$validator = new RecordExists(['table' => 'users',
106-
'field' => 'field1',
107-
'adapter' => $this->getMockHasResult()]);
115+
$validator = new RecordExists([
116+
'table' => 'users',
117+
'field' => 'field1',
118+
'adapter' => $this->getMockHasResult()
119+
]);
108120
$this->assertTrue($validator->isValid('value1'));
109121
}
110122

@@ -197,8 +209,10 @@ public function testExcludeConstructor()
197209
public function testThrowsExceptionWithNoAdapter()
198210
{
199211
$validator = new RecordExists('users', 'field1', 'id != 1');
200-
$this->setExpectedException('Zend\Validator\Exception\RuntimeException',
201-
'No database adapter present');
212+
$this->setExpectedException(
213+
'Zend\Validator\Exception\RuntimeException',
214+
'No database adapter present'
215+
);
202216
$validator->isValid('nosuchvalue');
203217
}
204218

@@ -209,8 +223,10 @@ public function testThrowsExceptionWithNoAdapter()
209223
*/
210224
public function testWithSchema()
211225
{
212-
$validator = new RecordExists(['table' => 'users', 'schema' => 'my'],
213-
'field1', null, $this->getMockHasResult());
226+
$validator = new RecordExists([
227+
'table' => 'users',
228+
'schema' => 'my'
229+
], 'field1', null, $this->getMockHasResult());
214230
$this->assertTrue($validator->isValid('value1'));
215231
}
216232

@@ -221,8 +237,10 @@ public function testWithSchema()
221237
*/
222238
public function testWithSchemaNoResult()
223239
{
224-
$validator = new RecordExists(['table' => 'users', 'schema' => 'my'],
225-
'field1', null, $this->getMockNoResult());
240+
$validator = new RecordExists([
241+
'table' => 'users',
242+
'schema' => 'my'
243+
], 'field1', null, $this->getMockNoResult());
226244
$this->assertFalse($validator->isValid('value1'));
227245
}
228246

@@ -232,8 +250,10 @@ public function testWithSchemaNoResult()
232250
*/
233251
public function testSelectAcknowledgesTableAndSchema()
234252
{
235-
$validator = new RecordExists(['table' => 'users', 'schema' => 'my'],
236-
'field1', null, $this->getMockHasResult());
253+
$validator = new RecordExists([
254+
'table' => 'users',
255+
'schema' => 'my'
256+
], 'field1', null, $this->getMockHasResult());
237257
$table = $validator->getSelect()->getRawState('table');
238258
$this->assertInstanceOf('Zend\Db\Sql\TableIdentifier', $table);
239259
$this->assertEquals(['users', 'my'], $table->getTableAndSchema());
@@ -242,8 +262,11 @@ public function testSelectAcknowledgesTableAndSchema()
242262
public function testEqualsMessageTemplates()
243263
{
244264
$validator = new RecordExists('users', 'field1');
245-
$this->assertAttributeEquals($validator->getOption('messageTemplates'),
246-
'messageTemplates', $validator);
265+
$this->assertAttributeEquals(
266+
$validator->getOption('messageTemplates'),
267+
'messageTemplates',
268+
$validator
269+
);
247270
}
248271

249272
/**

0 commit comments

Comments
 (0)