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
19f8430c
Commit
19f8430c
authored
Jan 18, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished the asset tests.
parent
9977ccb7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
8 deletions
+138
-8
asset.php
laravel/asset.php
+1
-1
config.php
laravel/config.php
+1
-1
asset.test.php
tests/cases/laravel/asset.test.php
+136
-6
No files found.
laravel/asset.php
View file @
19f8430c
...
@@ -254,7 +254,7 @@ class Asset_Container {
...
@@ -254,7 +254,7 @@ class Asset_Container {
// ensure that we attach the correct path to the asset.
// ensure that we attach the correct path to the asset.
if
(
filter_var
(
$asset
[
'source'
],
FILTER_VALIDATE_URL
)
===
false
)
if
(
filter_var
(
$asset
[
'source'
],
FILTER_VALIDATE_URL
)
===
false
)
{
{
$asset
[
'source'
]
=
Bundle
::
assets
(
$this
->
bundle
)
.
$asset
[
'source'
]
;
$asset
[
'source'
]
=
$this
->
path
(
$asset
[
'source'
])
;
}
}
return
HTML
::
$group
(
$asset
[
'source'
],
$asset
[
'attributes'
]);
return
HTML
::
$group
(
$asset
[
'source'
],
$asset
[
'attributes'
]);
...
...
laravel/config.php
View file @
19f8430c
...
@@ -18,7 +18,7 @@ class Config {
...
@@ -18,7 +18,7 @@ class Config {
*
*
* @var array
* @var array
*/
*/
p
rotected
static
$cache
=
array
();
p
ublic
static
$cache
=
array
();
/**
/**
* Determine if a configuration item or file exists.
* Determine if a configuration item or file exists.
...
...
tests/cases/laravel/asset.test.php
View file @
19f8430c
...
@@ -7,6 +7,8 @@ class AssetTest extends PHPUnit_Framework_TestCase {
...
@@ -7,6 +7,8 @@ class AssetTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
setUp
()
public
function
setUp
()
{
{
Config
::
$items
=
array
();
Config
::
$cache
=
array
();
Asset
::
$containers
=
array
();
Asset
::
$containers
=
array
();
}
}
...
@@ -52,7 +54,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
...
@@ -52,7 +54,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testNameIsSetOnAssetContainerConstruction
()
public
function
testNameIsSetOnAssetContainerConstruction
()
{
{
$container
=
new
Laravel\Asset_Container
(
'foo'
);
$container
=
$this
->
getContainer
(
);
$this
->
assertEquals
(
'foo'
,
$container
->
name
);
$this
->
assertEquals
(
'foo'
,
$container
->
name
);
}
}
...
@@ -64,7 +66,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
...
@@ -64,7 +66,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testAddMethodProperlySniffsAssetType
()
public
function
testAddMethodProperlySniffsAssetType
()
{
{
$container
=
new
Laravel\Asset_Container
(
'foo'
);
$container
=
$this
->
getContainer
(
);
$container
->
add
(
'jquery'
,
'jquery.js'
);
$container
->
add
(
'jquery'
,
'jquery.js'
);
$container
->
add
(
'common'
,
'common.css'
);
$container
->
add
(
'common'
,
'common.css'
);
...
@@ -80,7 +82,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
...
@@ -80,7 +82,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testStyleMethodProperlyRegistersAnAsset
()
public
function
testStyleMethodProperlyRegistersAnAsset
()
{
{
$container
=
new
Laravel\Asset_Container
(
'foo'
);
$container
=
$this
->
getContainer
(
);
$container
->
style
(
'common'
,
'common.css'
);
$container
->
style
(
'common'
,
'common.css'
);
...
@@ -94,7 +96,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
...
@@ -94,7 +96,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testStyleMethodProperlySetsMediaAttributeIfNotSet
()
public
function
testStyleMethodProperlySetsMediaAttributeIfNotSet
()
{
{
$container
=
new
Laravel\Asset_Container
(
'foo'
);
$container
=
$this
->
getContainer
(
);
$container
->
style
(
'common'
,
'common.css'
);
$container
->
style
(
'common'
,
'common.css'
);
...
@@ -108,7 +110,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
...
@@ -108,7 +110,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testStyleMethodProperlyIgnoresMediaAttributeIfSet
()
public
function
testStyleMethodProperlyIgnoresMediaAttributeIfSet
()
{
{
$container
=
new
Laravel\Asset_Container
(
'foo'
);
$container
=
$this
->
getContainer
(
);
$container
->
style
(
'common'
,
'common.css'
,
array
(),
array
(
'media'
=>
'print'
));
$container
->
style
(
'common'
,
'common.css'
,
array
(),
array
(
'media'
=>
'print'
));
...
@@ -122,11 +124,139 @@ class AssetTest extends PHPUnit_Framework_TestCase {
...
@@ -122,11 +124,139 @@ class AssetTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testScriptMethodProperlyRegistersAnAsset
()
public
function
testScriptMethodProperlyRegistersAnAsset
()
{
{
$container
=
new
Laravel\Asset_Container
(
'foo'
);
$container
=
$this
->
getContainer
(
);
$container
->
script
(
'jquery'
,
'jquery.js'
);
$container
->
script
(
'jquery'
,
'jquery.js'
);
$this
->
assertEquals
(
'jquery.js'
,
$container
->
assets
[
'script'
][
'jquery'
][
'source'
]);
$this
->
assertEquals
(
'jquery.js'
,
$container
->
assets
[
'script'
][
'jquery'
][
'source'
]);
}
}
/**
* Test the Asset_Container::add method properly sets dependencies.
*
* @group laravel
*/
public
function
testAddMethodProperlySetsDependencies
()
{
$container
=
$this
->
getContainer
();
$container
->
add
(
'common'
,
'common.css'
,
'jquery'
);
$container
->
add
(
'jquery'
,
'jquery.js'
,
array
(
'jquery-ui'
));
$this
->
assertEquals
(
array
(
'jquery'
),
$container
->
assets
[
'style'
][
'common'
][
'dependencies'
]);
$this
->
assertEquals
(
array
(
'jquery-ui'
),
$container
->
assets
[
'script'
][
'jquery'
][
'dependencies'
]);
}
/**
* Test the Asset_Container::add method properly sets attributes.
*
* @group laravel
*/
public
function
testAddMethodProperlySetsAttributes
()
{
$container
=
$this
->
getContainer
();
$container
->
add
(
'common'
,
'common.css'
,
array
(),
array
(
'media'
=>
'print'
));
$container
->
add
(
'jquery'
,
'jquery.js'
,
array
(),
array
(
'defer'
));
$this
->
assertEquals
(
array
(
'media'
=>
'print'
),
$container
->
assets
[
'style'
][
'common'
][
'attributes'
]);
$this
->
assertEquals
(
array
(
'defer'
),
$container
->
assets
[
'script'
][
'jquery'
][
'attributes'
]);
}
/**
* Test the Asset_Container::bundle method.
*
* @group laravel
*/
public
function
testBundleMethodCorrectlySetsTheAssetBundle
()
{
$container
=
$this
->
getContainer
();
$container
->
bundle
(
'eloquent'
);
$this
->
assertEquals
(
'eloquent'
,
$container
->
bundle
);
}
/**
* Test the Asset_Container::path method.
*
* @group laravel
*/
public
function
testPathMethodReturnsCorrectPathForABundleAsset
()
{
Config
::
$cache
[
'application.url'
]
=
'http://localhost'
;
$container
=
$this
->
getContainer
();
$container
->
bundle
(
'eloquent'
);
$this
->
assertEquals
(
'http://localhost/bundles/eloquent/foo.jpg'
,
$container
->
path
(
'foo.jpg'
));
}
/**
* Test the Asset_Container::path method.
*
* @group laravel
*/
public
function
testPathMethodReturnsCorrectPathForAnApplicationAsset
()
{
Config
::
$cache
[
'application.url'
]
=
'http://localhost'
;
$container
=
$this
->
getContainer
();
$this
->
assertEquals
(
'http://localhost/foo.jpg'
,
$container
->
path
(
'foo.jpg'
));
}
/**
* Test the Asset_Container::scripts method.
*
* @group laravel
*/
public
function
testScriptsCanBeRetrieved
()
{
$container
=
$this
->
getContainer
();
$container
->
script
(
'dojo'
,
'dojo.js'
,
array
(
'jquery-ui'
));
$container
->
script
(
'jquery'
,
'jquery.js'
,
array
(
'jquery-ui'
,
'dojo'
));
$container
->
script
(
'jquery-ui'
,
'jquery-ui.js'
);
$scripts
=
$container
->
scripts
();
$this
->
assertTrue
(
strpos
(
$scripts
,
'jquery.js'
)
>
0
);
$this
->
assertTrue
(
strpos
(
$scripts
,
'jquery.js'
)
>
strpos
(
$scripts
,
'jquery-ui.js'
));
$this
->
assertTrue
(
strpos
(
$scripts
,
'dojo.js'
)
>
strpos
(
$scripts
,
'jquery-ui.js'
));
}
/**
* Test the Asset_Container::styles method.
*
* @group laravel
*/
public
function
testStylesCanBeRetrieved
()
{
$container
=
$this
->
getContainer
();
$container
->
style
(
'dojo'
,
'dojo.css'
,
array
(
'jquery-ui'
),
array
(
'media'
=>
'print'
));
$container
->
style
(
'jquery'
,
'jquery.css'
,
array
(
'jquery-ui'
,
'dojo'
));
$container
->
style
(
'jquery-ui'
,
'jquery-ui.css'
);
$styles
=
$container
->
styles
();
$this
->
assertTrue
(
strpos
(
$styles
,
'jquery.css'
)
>
0
);
$this
->
assertTrue
(
strpos
(
$styles
,
'media="print"'
)
>
0
);
$this
->
assertTrue
(
strpos
(
$styles
,
'jquery.css'
)
>
strpos
(
$styles
,
'jquery-ui.css'
));
$this
->
assertTrue
(
strpos
(
$styles
,
'dojo.css'
)
>
strpos
(
$styles
,
'jquery-ui.css'
));
}
/**
* Get an asset container instance.
*
* @param string $name
* @return Asset_Container
*/
private
function
getContainer
(
$name
=
'foo'
)
{
return
new
Laravel\Asset_Container
(
$name
);
}
}
}
\ 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