Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
PSDI Army
yii2
Commits
0c113faf
Commit
0c113faf
authored
Oct 11, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit test for asset bundles
parent
8bff031f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
0 deletions
+88
-0
.gitignore
tests/unit/data/web/assets/.gitignore
+3
-0
AssetBundleTest.php
tests/unit/framework/web/AssetBundleTest.php
+85
-0
No files found.
tests/unit/data/web/assets/.gitignore
0 → 100644
View file @
0c113faf
*
!.gitignore
\ No newline at end of file
tests/unit/framework/web/AssetBundleTest.php
0 → 100644
View file @
0c113faf
<?php
/**
*
*
* @author Carsten Brandt <mail@cebe.cc>
*/
namespace
yiiunit\framework\web
;
use
Yii
;
use
yii\base\View
;
use
yii\web\AssetBundle
;
use
yii\web\AssetManager
;
/**
* @group web
*/
class
AssetBundleTest
extends
\yiiunit\TestCase
{
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
mockApplication
();
Yii
::
setAlias
(
'@testWeb'
,
'/'
);
Yii
::
setAlias
(
'@testWebRoot'
,
'@yiiunit/data/web'
);
}
protected
function
getView
()
{
$view
=
new
View
();
$view
->
setAssetManager
(
new
AssetManager
(
array
(
'basePath'
=>
'@testWebRoot/assets'
,
'baseUrl'
=>
'@testWeb/assets'
,
)));
return
$view
;
}
public
function
testRegister
()
{
$view
=
$this
->
getView
();
$this
->
assertEmpty
(
$view
->
assetBundles
);
TestJqueryAsset
::
register
(
$view
);
$this
->
assertEquals
(
1
,
count
(
$view
->
assetBundles
));
$this
->
assertArrayHasKey
(
'yiiunit\\framework\\web\\TestJqueryAsset'
,
$view
->
assetBundles
);
}
public
function
testSimpleDependency
()
{
$view
=
$this
->
getView
();
$this
->
assertEmpty
(
$view
->
assetBundles
);
TestAssetBundle
::
register
(
$view
);
$this
->
assertEquals
(
2
,
count
(
$view
->
assetBundles
));
$this
->
assertArrayHasKey
(
'yiiunit\\framework\\web\\TestAssetBundle'
,
$view
->
assetBundles
);
$this
->
assertArrayHasKey
(
'yiiunit\\framework\\web\\TestJqueryAsset'
,
$view
->
assetBundles
);
}
}
class
TestAssetBundle
extends
AssetBundle
{
public
$basePath
=
'@testWebRoot/files'
;
public
$baseUrl
=
'@testWeb/files'
;
public
$css
=
array
(
'cssFile.css'
,
);
public
$js
=
array
(
'jsFile.js'
,
);
public
$depends
=
array
(
'yiiunit\\framework\\web\\TestJqueryAsset'
);
}
class
TestJqueryAsset
extends
AssetBundle
{
public
$basePath
=
'@testWebRoot/js'
;
public
$baseUrl
=
'@testWeb/js'
;
public
$js
=
array
(
'jquery.js'
,
);
}
\ 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