Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
018d25c8
Commit
018d25c8
authored
Sep 05, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit tests.
parent
cb8e8194
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
6 deletions
+95
-6
benchmark.php
laravel/benchmark.php
+3
-3
config.php
laravel/config.php
+1
-1
container.php
laravel/container.php
+2
-2
ArrTest.php
tests/ArrTest.php
+4
-0
BenchmarkTest.php
tests/BenchmarkTest.php
+13
-0
ConfigTest.php
tests/ConfigTest.php
+72
-0
No files found.
laravel/benchmark.php
View file @
018d25c8
...
@@ -7,7 +7,7 @@ class Benchmark {
...
@@ -7,7 +7,7 @@ class Benchmark {
*
*
* @var array
* @var array
*/
*/
p
ublic
static
$marks
=
array
();
p
rotected
static
$marks
=
array
();
/**
/**
* Start a benchmark.
* Start a benchmark.
...
@@ -32,10 +32,10 @@ class Benchmark {
...
@@ -32,10 +32,10 @@ class Benchmark {
{
{
if
(
array_key_exists
(
$name
,
static
::
$marks
))
if
(
array_key_exists
(
$name
,
static
::
$marks
))
{
{
return
number_format
((
microtime
(
true
)
-
static
::
$marks
[
$name
])
*
1000
,
2
);
return
(
float
)
number_format
((
microtime
(
true
)
-
static
::
$marks
[
$name
])
*
1000
,
2
);
}
}
return
0.0
;
return
(
float
)
0.0
;
}
}
/**
/**
...
...
laravel/config.php
View file @
018d25c8
...
@@ -119,7 +119,7 @@ class Config {
...
@@ -119,7 +119,7 @@ class Config {
* @param string $file
* @param string $file
* @return bool
* @return bool
*/
*/
pr
ivate
function
load
(
$file
)
pr
otected
function
load
(
$file
)
{
{
if
(
isset
(
$this
->
items
[
$file
]))
return
true
;
if
(
isset
(
$this
->
items
[
$file
]))
return
true
;
...
...
laravel/container.php
View file @
018d25c8
...
@@ -39,14 +39,14 @@ class Container {
...
@@ -39,14 +39,14 @@ class Container {
*
*
* @var array
* @var array
*/
*/
p
rivate
$singletons
=
array
();
p
ublic
$singletons
=
array
();
/**
/**
* The registered dependencies.
* The registered dependencies.
*
*
* @var array
* @var array
*/
*/
pr
ivate
$resolvers
=
array
();
pr
otected
$resolvers
=
array
();
/**
/**
* Create a new IoC container instance.
* Create a new IoC container instance.
...
...
tests/ArrTest.php
View file @
018d25c8
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
class
ArrTest
extends
PHPUnit_Framework_TestCase
{
class
ArrTest
extends
PHPUnit_Framework_TestCase
{
/**
/**
* @dataProvider getArray
* @dataProvider getArray
*/
*/
...
@@ -11,6 +12,7 @@ class ArrTest extends PHPUnit_Framework_TestCase {
...
@@ -11,6 +12,7 @@ class ArrTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
Arr
::
get
(
$array
,
'names.uncle'
),
$array
[
'names'
][
'uncle'
]);
$this
->
assertEquals
(
Arr
::
get
(
$array
,
'names.uncle'
),
$array
[
'names'
][
'uncle'
]);
}
}
/**
/**
* @dataProvider getArray
* @dataProvider getArray
*/
*/
...
@@ -21,6 +23,7 @@ class ArrTest extends PHPUnit_Framework_TestCase {
...
@@ -21,6 +23,7 @@ class ArrTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
Arr
::
get
(
$array
,
'names.aunt'
,
function
()
{
return
'Tammy'
;}),
'Tammy'
);
$this
->
assertEquals
(
Arr
::
get
(
$array
,
'names.aunt'
,
function
()
{
return
'Tammy'
;}),
'Tammy'
);
}
}
/**
/**
* @dataProvider getArray
* @dataProvider getArray
*/
*/
...
@@ -36,6 +39,7 @@ class ArrTest extends PHPUnit_Framework_TestCase {
...
@@ -36,6 +39,7 @@ class ArrTest extends PHPUnit_Framework_TestCase {
}
}
public
function
getArray
()
public
function
getArray
()
{
{
return
array
(
array
(
return
array
(
array
(
...
...
tests/BenchmarkTest.php
0 → 100644
View file @
018d25c8
<?php
class
BenchmarkTest
extends
PHPUnit_Framework_TestCase
{
public
function
testStartMethodCreatesMark
()
{
Benchmark
::
start
(
'test'
);
$this
->
assertTrue
(
is_float
(
Benchmark
::
check
(
'test'
)));
$this
->
assertGreaterThan
(
0.0
,
Benchmark
::
check
(
'test'
));
}
}
\ No newline at end of file
tests/ConfigTest.php
0 → 100644
View file @
018d25c8
<?php
class
ConfigTest
extends
PHPUnit_Framework_TestCase
{
public
function
setUp
()
{
IoC
::
container
()
->
singletons
=
array
();
}
/**
* @dataProvider getGetMocker
*/
public
function
testHasMethodReturnsTrueWhenItemExists
(
$mock
,
$mocker
)
{
$mocker
->
will
(
$this
->
returnValue
(
'value'
));
$this
->
assertTrue
(
$mock
->
has
(
'something'
));
}
/**
* @dataProvider getGetMocker
*/
public
function
testHasMethodReturnsFalseWhenItemDoesntExist
(
$mock
,
$mocker
)
{
$mocker
->
will
(
$this
->
returnValue
(
null
));
$this
->
assertFalse
(
$mock
->
has
(
'something'
));
}
public
function
getGetMocker
()
{
$mock
=
$this
->
getMock
(
'Laravel\\Config'
,
array
(
'get'
),
array
(
null
));
return
array
(
array
(
$mock
,
$mock
->
expects
(
$this
->
any
())
->
method
(
'get'
)));
}
public
function
testConfigClassCanRetrieveItems
()
{
$config
=
IoC
::
container
()
->
config
;
$this
->
assertTrue
(
is_array
(
$config
->
get
(
'application'
)));
$this
->
assertEquals
(
$config
->
get
(
'application.url'
),
'http://localhost'
);
}
public
function
testGetMethodReturnsDefaultWhenItemDoesntExist
()
{
$config
=
IoC
::
container
()
->
config
;
$this
->
assertNull
(
$config
->
get
(
'config.item'
));
$this
->
assertEquals
(
$config
->
get
(
'config.item'
,
'test'
),
'test'
);
$this
->
assertEquals
(
$config
->
get
(
'config.item'
,
function
()
{
return
'test'
;}),
'test'
);
}
public
function
testConfigClassCanSetItems
()
{
$config
=
IoC
::
container
()
->
config
;
$config
->
set
(
'application.url'
,
'test'
);
$config
->
set
(
'session'
,
array
());
$this
->
assertEquals
(
$config
->
get
(
'application.url'
),
'test'
);
$this
->
assertEquals
(
$config
->
get
(
'session'
),
array
());
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment