FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Validation/ValidationFactoryTest.php at master · JavaDevl/framework · GitHub
JavaDevl
/
framework
Public
forked from
laravel/framework
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
tests
/
Validation
/
ValidationFactoryTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
63 lines (55 loc) · 2.72 KB
Breadcrumbs
framework
/
tests
/
Validation
/
ValidationFactoryTest.php
Copy path
File metadata and controls
executable file
·
63 lines (55 loc) · 2.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use
Mockery
as
m
;
use
Illuminate
\
Validation
\
Factory
;
class
ValidationFactoryTest
extends
PHPUnit_Framework_TestCase
{
public
function
tearDown
()
{
m::
close
();
}
public
function
testMakeMethodCreatesValidValidator
()
{
$
translator
= m::
mock
(
'
Symfony\Component\Translation\TranslatorInterface
'
);
$
factory
=
new
Factory
(
$
translator
);
$
validator
=
$
factory
->
make
([
'
foo
'
=>
'
bar
'
], [
'
baz
'
=>
'
boom
'
]);
$
this
->
assertEquals
(
$
translator
,
$
validator
->
getTranslator
());
$
this
->
assertEquals
([
'
foo
'
=>
'
bar
'
],
$
validator
->
getData
());
$
this
->
assertEquals
([
'
baz
'
=> [
'
boom
'
]],
$
validator
->
getRules
());
$
presence
= m::
mock
(
'
Illuminate\Validation\PresenceVerifierInterface
'
);
$
noop1
=
function
() {};
$
noop2
=
function
() {};
$
noop3
=
function
() {};
$
factory
->
extend
(
'
foo
'
,
$
noop1
);
$
factory
->
extendImplicit
(
'
implicit
'
,
$
noop2
);
$
factory
->
replacer
(
'
replacer
'
,
$
noop3
);
$
factory
->
setPresenceVerifier
(
$
presence
);
$
validator
=
$
factory
->
make
([], []);
$
this
->
assertEquals
([
'
foo
'
=>
$
noop1
,
'
implicit
'
=>
$
noop2
],
$
validator
->
getExtensions
());
$
this
->
assertEquals
([
'
replacer
'
=>
$
noop3
],
$
validator
->
getReplacers
());
$
this
->
assertEquals
(
$
presence
,
$
validator
->
getPresenceVerifier
());
$
presence
= m::
mock
(
'
Illuminate\Validation\PresenceVerifierInterface
'
);
$
factory
->
extend
(
'
foo
'
,
$
noop1
,
'
foo!
'
);
$
factory
->
extendImplicit
(
'
implicit
'
,
$
noop2
,
'
implicit!
'
);
$
factory
->
setPresenceVerifier
(
$
presence
);
$
validator
=
$
factory
->
make
([], []);
$
this
->
assertEquals
([
'
foo
'
=>
$
noop1
,
'
implicit
'
=>
$
noop2
],
$
validator
->
getExtensions
());
$
this
->
assertEquals
([
'
foo
'
=>
'
foo!
'
,
'
implicit
'
=>
'
implicit!
'
],
$
validator
->
getFallbackMessages
());
$
this
->
assertEquals
(
$
presence
,
$
validator
->
getPresenceVerifier
());
}
public
function
testCustomResolverIsCalled
()
{
unset(
$
_SERVER
[
'
__validator.factory
'
]);
$
translator
= m::
mock
(
'
Symfony\Component\Translation\TranslatorInterface
'
);
$
factory
=
new
Factory
(
$
translator
);
$
factory
->
resolver
(
function
(
$
translator
,
$
data
,
$
rules
) {
$
_SERVER
[
'
__validator.factory
'
] =
true
;
return
new
Illuminate
\
Validation
\
Validator
(
$
translator
,
$
data
,
$
rules
);
});
$
validator
=
$
factory
->
make
([
'
foo
'
=>
'
bar
'
], [
'
baz
'
=>
'
boom
'
]);
$
this
->
assertTrue
(
$
_SERVER
[
'
__validator.factory
'
]);
$
this
->
assertEquals
(
$
translator
,
$
validator
->
getTranslator
());
$
this
->
assertEquals
([
'
foo
'
=>
'
bar
'
],
$
validator
->
getData
());
$
this
->
assertEquals
([
'
baz
'
=> [
'
boom
'
]],
$
validator
->
getRules
());
unset(
$
_SERVER
[
'
__validator.factory
'
]);
}
}
Back
|
FazBrowse Home
|
New Git URL