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

Commit 124cbfb

Browse files
committed
Merge pull request #223 from codisart/tidy-unit-tests
issue#27 - Tidy some misplaced unit tests
2 parents 0828ee6 + 547eab8 commit 124cbfb

File tree

3 files changed

+19
-42
lines changed

3 files changed

+19
-42
lines changed

test/AbstractTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ public function testCanSetTranslatorToNull()
6565
$this->assertNull($this->validator->getTranslator());
6666
}
6767

68-
public function testGlobalDefaultTranslatorNullByDefault()
69-
{
70-
$this->assertNull(AbstractValidator::getDefaultTranslator());
71-
}
72-
7368
public function testErrorMessagesAreTranslatedWhenTranslatorPresent()
7469
{
7570
if (! extension_loaded('intl')) {

test/StaticValidatorTest.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
namespace ZendTest\Validator;
1111

1212
use PHPUnit\Framework\TestCase;
13-
use Zend\Validator\AbstractValidator;
1413
use Zend\I18n\Validator\Alpha;
14+
use Zend\ServiceManager\Exception\ServiceNotFoundException;
15+
use Zend\ServiceManager\ServiceManager;
16+
use Zend\Validator\AbstractValidator;
1517
use Zend\Validator\Between;
16-
use Zend\Validator\StaticValidator;
1718
use Zend\Validator\ValidatorPluginManager;
18-
use Zend\ServiceManager\ServiceManager;
19+
use Zend\Validator\StaticValidator;
1920

2021
/**
2122
* @group Zend_Validator
@@ -167,4 +168,19 @@ public function testExecuteRaisesExceptionForIndexedOptionsArray($value, $valida
167168
$this->expectExceptionMessage('options');
168169
StaticValidator::execute($value, $validator, $options);
169170
}
171+
172+
/**
173+
* Ensures that if we specify a validator class basename that doesn't
174+
* exist in the namespace, is() throws an exception.
175+
*
176+
* Refactored to conform with ZF-2724.
177+
*
178+
* @group ZF-2724
179+
* @return void
180+
*/
181+
public function testStaticFactoryClassNotFound()
182+
{
183+
$this->expectException(ServiceNotFoundException::class);
184+
StaticValidator::execute('1234', 'UnknownValidator');
185+
}
170186
}

test/ValidatorChainTest.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Zend\Validator\NotEmpty;
1616
use Zend\Validator\StaticValidator;
1717
use Zend\Validator\ValidatorChain;
18-
use Zend\ServiceManager\Exception\ServiceNotFoundException;
1918
use Zend\Validator\ValidatorInterface;
2019
use Zend\Validator\GreaterThan;
2120

@@ -100,39 +99,6 @@ public function testBreakChainOnFailure()
10099
$this->assertEquals(['error' => 'validation failed'], $this->validator->getMessages());
101100
}
102101

103-
/**
104-
* Ensures that if we specify a validator class basename that doesn't
105-
* exist in the namespace, is() throws an exception.
106-
*
107-
* Refactored to conform with ZF-2724.
108-
*
109-
* @group ZF-2724
110-
* @return void
111-
*/
112-
public function testStaticFactoryClassNotFound()
113-
{
114-
$this->expectException(ServiceNotFoundException::class);
115-
StaticValidator::execute('1234', 'UnknownValidator');
116-
}
117-
118-
public function testSetGetMessageLengthLimitation()
119-
{
120-
AbstractValidator::setMessageLength(5);
121-
$this->assertEquals(5, AbstractValidator::getMessageLength());
122-
123-
$valid = new Between(1, 10);
124-
$this->assertFalse($valid->isValid(24));
125-
$message = current($valid->getMessages());
126-
$this->assertLessThanOrEqual(5, strlen($message));
127-
}
128-
129-
public function testSetGetDefaultTranslator()
130-
{
131-
$translator = new TestAsset\Translator();
132-
AbstractValidator::setDefaultTranslator($translator);
133-
$this->assertSame($translator, AbstractValidator::getDefaultTranslator());
134-
}
135-
136102
public function testAllowsPrependingValidators()
137103
{
138104
$this->validator->attach($this->getValidatorTrue())

0 commit comments

Comments
 (0)