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
6a193f38
Commit
6a193f38
authored
Mar 08, 2014
by
Johnny Theill
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/yiisoft/yii2
into travis-advanced-app
parents
af8f1e25
bd3dd038
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
268 additions
and
101 deletions
+268
-101
.travis.yml
.travis.yml
+2
-0
LoginCept.php
apps/advanced/backend/tests/acceptance/LoginCept.php
+11
-9
LoginCept.php
apps/advanced/backend/tests/functional/LoginCept.php
+6
-9
ContactCept.php
apps/advanced/frontend/tests/acceptance/ContactCept.php
+10
-10
LoginCept.php
apps/advanced/frontend/tests/acceptance/LoginCept.php
+11
-9
SignupCest.php
apps/advanced/frontend/tests/acceptance/SignupCest.php
+9
-9
ContactCept.php
apps/advanced/frontend/tests/functional/ContactCept.php
+10
-10
LoginCept.php
apps/advanced/frontend/tests/functional/LoginCept.php
+6
-9
SignupCest.php
apps/advanced/frontend/tests/functional/SignupCest.php
+17
-9
ContactFormTest.php
apps/advanced/frontend/tests/unit/models/ContactFormTest.php
+3
-3
rest.md
docs/guide/rest.md
+1
-0
upgrade-from-v1.md
docs/guide/upgrade-from-v1.md
+2
-1
ApiMarkdown.php
extensions/apidoc/helpers/ApiMarkdown.php
+1
-1
BaseRenderer.php
extensions/apidoc/renderers/BaseRenderer.php
+1
-1
style.css
extensions/apidoc/templates/bootstrap/assets/css/style.css
+6
-2
ApiRenderer.php
extensions/apidoc/templates/html/ApiRenderer.php
+5
-4
methodDetails.php
extensions/apidoc/templates/html/views/methodDetails.php
+4
-4
Collection.php
extensions/mongodb/Collection.php
+66
-2
README.md
extensions/mongodb/README.md
+31
-0
ActiveRecord.php
extensions/mongodb/file/ActiveRecord.php
+10
-0
TwigSimpleFileLoader.php
extensions/twig/TwigSimpleFileLoader.php
+2
-2
Widget.php
framework/base/Widget.php
+1
-1
AssetController.php
framework/console/controllers/AssetController.php
+3
-2
HttpBearerAuth.php
framework/rest/HttpBearerAuth.php
+1
-1
User.php
framework/web/User.php
+1
-1
DetailView.php
framework/widgets/DetailView.php
+1
-1
ListView.php
framework/widgets/ListView.php
+1
-1
CollectionTest.php
tests/unit/extensions/mongodb/CollectionTest.php
+45
-0
ActiveRecordTest.php
tests/unit/extensions/mongodb/file/ActiveRecordTest.php
+1
-0
No files found.
.travis.yml
View file @
6a193f38
...
...
@@ -63,5 +63,7 @@ script:
-
cd ../frontend && ../vendor/bin/codecept run
after_script
:
-
cd ../..
-
pwd
-
wget https://scrutinizer-ci.com/ocular.phar
-
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
apps/advanced/backend/tests/acceptance/LoginCept.php
View file @
6a193f38
...
...
@@ -10,21 +10,23 @@ $loginPage = LoginPage::openBy($I);
$I
->
amGoingTo
(
'submit login form with no data'
);
$loginPage
->
login
(
''
,
''
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Username cannot be blank.'
);
$I
->
see
(
'Password cannot be blank.'
);
$I
->
see
(
'Username cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Password cannot be blank.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with wrong credentials'
);
$I
->
expectTo
(
'see validations errors'
);
$loginPage
->
login
(
'admin'
,
'wrong'
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Incorrect username or password.'
);
$I
->
see
(
'Incorrect username or password.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with correct credentials'
);
$loginPage
->
login
(
'erau'
,
'password_0'
);
$I
->
expectTo
(
'see that user is logged'
);
$I
->
see
(
'Logout (erau)'
);
$I
->
dontSee
(
'Login'
);
$I
->
dontSee
(
'Signup'
);
$I
->
click
(
'Logout (erau)'
);
$I
->
dontSee
(
'Logout (erau)'
);
$I
->
see
(
'Login'
);
$I
->
seeLink
(
'Logout (erau)'
);
$I
->
dontSeeLink
(
'Login'
);
$I
->
dontSeeLink
(
'Signup'
);
/** Uncomment if using WebDriver
* $I->click('Logout (erau)');
* $I->dontSeeLink('Logout (erau)');
* $I->seeLink('Login');
*/
apps/advanced/backend/tests/functional/LoginCept.php
View file @
6a193f38
...
...
@@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I);
$I
->
amGoingTo
(
'submit login form with no data'
);
$loginPage
->
login
(
''
,
''
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Username cannot be blank.'
);
$I
->
see
(
'Password cannot be blank.'
);
$I
->
see
(
'Username cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Password cannot be blank.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with wrong credentials'
);
$I
->
expectTo
(
'see validations errors'
);
$loginPage
->
login
(
'admin'
,
'wrong'
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Incorrect username or password.'
);
$I
->
see
(
'Incorrect username or password.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with correct credentials'
);
$loginPage
->
login
(
'erau'
,
'password_0'
);
$I
->
expectTo
(
'see that user is logged'
);
$I
->
see
(
'Logout (erau)'
);
$I
->
dontSee
(
'Login'
);
$I
->
dontSee
(
'Signup'
);
$I
->
click
(
'Logout (erau)'
);
$I
->
dontSee
(
'Logout (erau)'
);
$I
->
see
(
'Login'
);
$I
->
seeLink
(
'Logout (erau)'
);
$I
->
dontSeeLink
(
'Login'
);
$I
->
dontSeeLink
(
'Signup'
);
apps/advanced/frontend/tests/acceptance/ContactCept.php
View file @
6a193f38
...
...
@@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data');
$contactPage
->
submit
([]);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Contact'
,
'h1'
);
$I
->
see
(
'Name cannot be blank'
);
$I
->
see
(
'Email cannot be blank'
);
$I
->
see
(
'Subject cannot be blank'
);
$I
->
see
(
'Body cannot be blank'
);
$I
->
see
(
'The verification code is incorrect'
);
$I
->
see
(
'Name cannot be blank'
,
'.help-block'
);
$I
->
see
(
'Email cannot be blank'
,
'.help-block'
);
$I
->
see
(
'Subject cannot be blank'
,
'.help-block'
);
$I
->
see
(
'Body cannot be blank'
,
'.help-block'
);
$I
->
see
(
'The verification code is incorrect'
,
'.help-block'
);
$I
->
amGoingTo
(
'submit contact form with not correct email'
);
$contactPage
->
submit
([
...
...
@@ -28,11 +28,11 @@ $contactPage->submit([
'verifyCode'
=>
'testme'
,
]);
$I
->
expectTo
(
'see that email adress is wrong'
);
$I
->
dontSee
(
'Name cannot be blank'
,
'.help-
inline
'
);
$I
->
see
(
'Email is not a valid email address.'
);
$I
->
dontSee
(
'Subject cannot be blank'
,
'.help-
inline
'
);
$I
->
dontSee
(
'Body cannot be blank'
,
'.help-
inline
'
);
$I
->
dontSee
(
'The verification code is incorrect'
,
'.help-
inline
'
);
$I
->
dontSee
(
'Name cannot be blank'
,
'.help-
block
'
);
$I
->
see
(
'Email is not a valid email address.'
,
'.help-block'
);
$I
->
dontSee
(
'Subject cannot be blank'
,
'.help-
block
'
);
$I
->
dontSee
(
'Body cannot be blank'
,
'.help-
block
'
);
$I
->
dontSee
(
'The verification code is incorrect'
,
'.help-
block
'
);
$I
->
amGoingTo
(
'submit contact form with correct data'
);
$contactPage
->
submit
([
...
...
apps/advanced/frontend/tests/acceptance/LoginCept.php
View file @
6a193f38
...
...
@@ -10,21 +10,23 @@ $loginPage = LoginPage::openBy($I);
$I
->
amGoingTo
(
'submit login form with no data'
);
$loginPage
->
login
(
''
,
''
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Username cannot be blank.'
);
$I
->
see
(
'Password cannot be blank.'
);
$I
->
see
(
'Username cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Password cannot be blank.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with wrong credentials'
);
$I
->
expectTo
(
'see validations errors'
);
$loginPage
->
login
(
'admin'
,
'wrong'
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Incorrect username or password.'
);
$I
->
see
(
'Incorrect username or password.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with correct credentials'
);
$loginPage
->
login
(
'erau'
,
'password_0'
);
$I
->
expectTo
(
'see that user is logged'
);
$I
->
see
(
'Logout (erau)'
);
$I
->
dontSee
(
'Login'
);
$I
->
dontSee
(
'Signup'
);
$I
->
click
(
'Logout (erau)'
);
$I
->
dontSee
(
'Logout (erau)'
);
$I
->
see
(
'Login'
);
$I
->
seeLink
(
'Logout (erau)'
);
$I
->
dontSeeLink
(
'Login'
);
$I
->
dontSeeLink
(
'Signup'
);
/** Uncomment if using WebDriver
* $I->click('Logout (erau)');
* $I->dontSeeLink('Logout (erau)');
* $I->seeLink('Login');
*/
apps/advanced/frontend/tests/acceptance/SignupCest.php
View file @
6a193f38
...
...
@@ -9,7 +9,7 @@ class SignupCest
{
/**
* This method is called
after
each cest class test method
* This method is called
before
each cest class test method
* @param \Codeception\Event\Test $event
*/
public
function
_before
(
$event
)
...
...
@@ -37,7 +37,6 @@ class SignupCest
}
/**
*
* @param \WebGuy $I
* @param \Codeception\Scenario $scenario
*/
...
...
@@ -46,6 +45,7 @@ class SignupCest
$I
->
wantTo
(
'ensure that signup works'
);
$signupPage
=
SignupPage
::
openBy
(
$I
);
$I
->
see
(
'Signup'
,
'h1'
);
$I
->
see
(
'Please fill out the following fields to signup:'
);
$I
->
amGoingTo
(
'submit signup form with no data'
);
...
...
@@ -53,9 +53,9 @@ class SignupCest
$signupPage
->
submit
([]);
$I
->
expectTo
(
'see validation errors'
);
$I
->
see
(
'Username cannot be blank.'
);
$I
->
see
(
'Email cannot be blank.'
);
$I
->
see
(
'Password cannot be blank.'
);
$I
->
see
(
'Username cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Email cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Password cannot be blank.'
,
'.help-block'
);
$I
->
amGoingTo
(
'submit signup form with not correct email'
);
$signupPage
->
submit
([
...
...
@@ -64,9 +64,9 @@ class SignupCest
'password'
=>
'tester_password'
,
]);
$I
->
expectTo
(
'see that email adress is wrong'
);
$I
->
dontSee
(
'Username cannot be blank.'
,
'.help-
inline
'
);
$I
->
dontSee
(
'Password cannot be blank.'
,
'.help-
inline
'
);
$I
->
expectTo
(
'see that email ad
d
ress is wrong'
);
$I
->
dontSee
(
'Username cannot be blank.'
,
'.help-
block
'
);
$I
->
dontSee
(
'Password cannot be blank.'
,
'.help-
block
'
);
$I
->
see
(
'Email is not a valid email address.'
,
'.help-block'
);
$I
->
amGoingTo
(
'submit signup form with correct email'
);
...
...
@@ -77,6 +77,6 @@ class SignupCest
]);
$I
->
expectTo
(
'see that user logged in'
);
$I
->
see
(
'Logout (tester)'
);
$I
->
see
Link
(
'Logout (tester)'
);
}
}
apps/advanced/frontend/tests/functional/ContactCept.php
View file @
6a193f38
...
...
@@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data');
$contactPage
->
submit
([]);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Contact'
,
'h1'
);
$I
->
see
(
'Name cannot be blank'
);
$I
->
see
(
'Email cannot be blank'
);
$I
->
see
(
'Subject cannot be blank'
);
$I
->
see
(
'Body cannot be blank'
);
$I
->
see
(
'The verification code is incorrect'
);
$I
->
see
(
'Name cannot be blank'
,
'.help-block'
);
$I
->
see
(
'Email cannot be blank'
,
'.help-block'
);
$I
->
see
(
'Subject cannot be blank'
,
'.help-block'
);
$I
->
see
(
'Body cannot be blank'
,
'.help-block'
);
$I
->
see
(
'The verification code is incorrect'
,
'.help-block'
);
$I
->
amGoingTo
(
'submit contact form with not correct email'
);
$contactPage
->
submit
([
...
...
@@ -28,11 +28,11 @@ $contactPage->submit([
'verifyCode'
=>
'testme'
,
]);
$I
->
expectTo
(
'see that email adress is wrong'
);
$I
->
dontSee
(
'Name cannot be blank'
,
'.help-
inline
'
);
$I
->
see
(
'Email is not a valid email address.'
);
$I
->
dontSee
(
'Subject cannot be blank'
,
'.help-
inline
'
);
$I
->
dontSee
(
'Body cannot be blank'
,
'.help-
inline
'
);
$I
->
dontSee
(
'The verification code is incorrect'
,
'.help-
inline
'
);
$I
->
dontSee
(
'Name cannot be blank'
,
'.help-
block
'
);
$I
->
see
(
'Email is not a valid email address.'
,
'.help-block'
);
$I
->
dontSee
(
'Subject cannot be blank'
,
'.help-
block
'
);
$I
->
dontSee
(
'Body cannot be blank'
,
'.help-
block
'
);
$I
->
dontSee
(
'The verification code is incorrect'
,
'.help-
block
'
);
$I
->
amGoingTo
(
'submit contact form with correct data'
);
$contactPage
->
submit
([
...
...
apps/advanced/frontend/tests/functional/LoginCept.php
View file @
6a193f38
...
...
@@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I);
$I
->
amGoingTo
(
'submit login form with no data'
);
$loginPage
->
login
(
''
,
''
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Username cannot be blank.'
);
$I
->
see
(
'Password cannot be blank.'
);
$I
->
see
(
'Username cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Password cannot be blank.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with wrong credentials'
);
$I
->
expectTo
(
'see validations errors'
);
$loginPage
->
login
(
'admin'
,
'wrong'
);
$I
->
expectTo
(
'see validations errors'
);
$I
->
see
(
'Incorrect username or password.'
);
$I
->
see
(
'Incorrect username or password.'
,
'.help-block'
);
$I
->
amGoingTo
(
'try to login with correct credentials'
);
$loginPage
->
login
(
'erau'
,
'password_0'
);
$I
->
expectTo
(
'see that user is logged'
);
$I
->
see
(
'Logout (erau)'
);
$I
->
dontSee
(
'Login'
);
$I
->
dontSee
(
'Signup'
);
$I
->
click
(
'Logout (erau)'
);
$I
->
dontSee
(
'Logout (erau)'
);
$I
->
see
(
'Login'
);
$I
->
seeLink
(
'Logout (erau)'
);
$I
->
dontSeeLink
(
'Login'
);
$I
->
dontSeeLink
(
'Signup'
);
apps/advanced/frontend/tests/functional/SignupCest.php
View file @
6a193f38
...
...
@@ -9,7 +9,7 @@ class SignupCest
{
/**
* This method is called
after
each cest class test method
* This method is called
before
each cest class test method
* @param \Codeception\Event\Test $event
*/
public
function
_before
(
$event
)
...
...
@@ -34,10 +34,11 @@ class SignupCest
*/
public
function
_fail
(
$event
)
{
}
/**
*
*
* @param \TestGuy $I
* @param \Codeception\Scenario $scenario
*/
...
...
@@ -46,6 +47,7 @@ class SignupCest
$I
->
wantTo
(
'ensure that signup works'
);
$signupPage
=
SignupPage
::
openBy
(
$I
);
$I
->
see
(
'Signup'
,
'h1'
);
$I
->
see
(
'Please fill out the following fields to signup:'
);
$I
->
amGoingTo
(
'submit signup form with no data'
);
...
...
@@ -53,9 +55,9 @@ class SignupCest
$signupPage
->
submit
([]);
$I
->
expectTo
(
'see validation errors'
);
$I
->
see
(
'Username cannot be blank.'
);
$I
->
see
(
'Email cannot be blank.'
);
$I
->
see
(
'Password cannot be blank.'
);
$I
->
see
(
'Username cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Email cannot be blank.'
,
'.help-block'
);
$I
->
see
(
'Password cannot be blank.'
,
'.help-block'
);
$I
->
amGoingTo
(
'submit signup form with not correct email'
);
$signupPage
->
submit
([
...
...
@@ -64,9 +66,9 @@ class SignupCest
'password'
=>
'tester_password'
,
]);
$I
->
expectTo
(
'see that email adress is wrong'
);
$I
->
dontSee
(
'Username cannot be blank.'
,
'.help-
inline
'
);
$I
->
dontSee
(
'Password cannot be blank.'
,
'.help-
inline
'
);
$I
->
expectTo
(
'see that email ad
d
ress is wrong'
);
$I
->
dontSee
(
'Username cannot be blank.'
,
'.help-
block
'
);
$I
->
dontSee
(
'Password cannot be blank.'
,
'.help-
block
'
);
$I
->
see
(
'Email is not a valid email address.'
,
'.help-block'
);
$I
->
amGoingTo
(
'submit signup form with correct email'
);
...
...
@@ -76,7 +78,13 @@ class SignupCest
'password'
=>
'tester_password'
,
]);
$I
->
expectTo
(
'see that user is created'
);
$I
->
seeRecord
(
'common\models\User'
,
[
'username'
=>
'tester'
,
'email'
=>
'tester.email@example.com'
,
]);
$I
->
expectTo
(
'see that user logged in'
);
$I
->
see
(
'Logout (tester)'
);
$I
->
see
Link
(
'Logout (tester)'
);
}
}
apps/advanced/frontend/tests/unit/models/ContactFormTest.php
View file @
6a193f38
...
...
@@ -4,6 +4,7 @@ namespace frontend\tests\unit\models;
use
Yii
;
use
frontend\tests\unit\TestCase
;
use
frontend\models\ContactForm
;
class
ContactFormTest
extends
TestCase
{
...
...
@@ -26,8 +27,7 @@ class ContactFormTest extends TestCase
public
function
testContact
()
{
$model
=
$this
->
getMock
(
'frontend\models\ContactForm'
,
[
'validate'
]);
$model
->
expects
(
$this
->
once
())
->
method
(
'validate'
)
->
will
(
$this
->
returnValue
(
true
));
$model
=
new
ContactForm
();
$model
->
attributes
=
[
'name'
=>
'Tester'
,
...
...
@@ -36,7 +36,7 @@ class ContactFormTest extends TestCase
'body'
=>
'body of current message'
,
];
$model
->
contact
(
'admin@example.com'
);
$model
->
sendEmail
(
'admin@example.com'
);
$this
->
specify
(
'email should be send'
,
function
()
{
expect
(
'email file should exist'
,
file_exists
(
$this
->
getMessageFile
()))
->
true
();
...
...
docs/guide/rest.md
View file @
6a193f38
...
...
@@ -381,6 +381,7 @@ the `self` link, for example:
```
php
use
yii\db\ActiveRecord
;
use
yii\web\Link
;
use
yii\web\Linkable
;
use
yii\helpers\Url
;
...
...
docs/guide/upgrade-from-v1.md
View file @
6a193f38
...
...
@@ -522,7 +522,8 @@ TBD
Extensions
----------
TBD
Yii 1.1 extensions are not compatible with 2.0 so you have to port or rewrite these. In order to get more info about
extensions in 2.0
[
referer to corresponding guide section
](
extensions.md
)
.
Integration with Composer
-------------------------
...
...
extensions/apidoc/helpers/ApiMarkdown.php
View file @
6a193f38
...
...
@@ -93,7 +93,7 @@ class ApiMarkdown extends GithubMarkdown
}
}
p
rotected
function
highlight
(
$code
,
$language
)
p
ublic
static
function
highlight
(
$code
,
$language
)
{
if
(
$language
!==
'php'
)
{
return
htmlspecialchars
(
$code
,
ENT_NOQUOTES
,
'UTF-8'
);
...
...
extensions/apidoc/renderers/BaseRenderer.php
View file @
6a193f38
...
...
@@ -117,7 +117,7 @@ abstract class BaseRenderer extends Component
$links
[]
=
$this
->
generateLink
(
$linkText
,
$this
->
generateApiUrl
(
$type
->
name
))
.
$postfix
;
}
}
return
implode
(
'
|
'
,
$links
);
return
implode
(
'
|
'
,
$links
);
}
...
...
extensions/apidoc/templates/bootstrap/assets/css/style.css
View file @
6a193f38
...
...
@@ -57,4 +57,9 @@ blockquote {
td
p
{
margin
:
0
;
}
\ No newline at end of file
}
table
.detailTable
.paramNameCol
{
width
:
15%
;
min-width
:
100px
;
}
table
.detailTable
.paramTypeCol
{
width
:
15%
;
min-width
:
150px
;
}
table
.detailTable
.paramDescCol
{
width
:
70%
;
}
extensions/apidoc/templates/html/ApiRenderer.php
View file @
6a193f38
...
...
@@ -7,6 +7,7 @@
namespace
yii\apidoc\templates\html
;
use
yii\apidoc\helpers\ApiMarkdown
;
use
yii\apidoc\models\MethodDoc
;
use
yii\apidoc\models\PropertyDoc
;
use
yii\apidoc\models\ClassDoc
;
...
...
@@ -225,7 +226,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
}
return
implode
(
'<br />'
,
$sig
);
}
return
$this
->
createTypeLink
(
$property
->
types
)
.
' '
.
$property
->
name
.
' = '
.
(
$property
->
defaultValue
===
null
?
'null'
:
$property
->
defaultValue
);
return
$this
->
createTypeLink
(
$property
->
types
)
.
' '
.
$this
->
createSubjectLink
(
$property
,
$property
->
name
)
.
' '
.
ApiMarkdown
::
highlight
(
'= '
.
(
$property
->
defaultValue
===
null
?
'null'
:
$property
->
defaultValue
),
'php'
);
}
/**
...
...
@@ -244,9 +246,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
return
(
$method
->
isReturnByReference
?
'<b>&</b>'
:
''
)
.
(
$method
->
returnType
===
null
?
'void'
:
$this
->
createTypeLink
(
$method
->
returnTypes
))
.
' '
.
$this
->
createSubjectLink
(
$method
,
$method
->
name
)
.
'( '
.
implode
(
', '
,
$params
)
.
' )'
;
.
' '
.
$this
->
createSubjectLink
(
$method
,
$method
->
name
)
.
ApiMarkdown
::
highlight
(
'( '
.
implode
(
', '
,
$params
)
.
' )'
,
'php'
);
}
public
function
generateApiUrl
(
$typeName
)
...
...
extensions/apidoc/templates/html/views/methodDetails.php
View file @
6a193f38
...
...
@@ -34,28 +34,28 @@ ArrayHelper::multisort($methods, 'name');
</span>
</div>
<table
class=
"
summary
Table table table-striped table-bordered table-hover"
>
<table
class=
"
detail
Table table table-striped table-bordered table-hover"
>
<tr><td
colspan=
"3"
>
<div
class=
"signature2"
>
<?=
$renderer
->
renderMethodSignature
(
$method
)
?>
</div>
</td></tr>
<?php
if
(
!
empty
(
$method
->
params
)
||
!
empty
(
$method
->
return
)
||
!
empty
(
$method
->
exceptions
))
:
?>
<?php
foreach
(
$method
->
params
as
$param
)
:
?>
<tr>
<td
class=
"paramNameCol"
>
<?=
$param
->
name
?>
</td>
<td
class=
"paramNameCol"
>
<?=
ApiMarkdown
::
highlight
(
$param
->
name
,
'php'
)
?>
</td>
<td
class=
"paramTypeCol"
>
<?=
$renderer
->
createTypeLink
(
$param
->
types
)
?>
</td>
<td
class=
"paramDescCol"
>
<?=
ApiMarkdown
::
process
(
$param
->
description
,
$type
)
?>
</td>
</tr>
<?php
endforeach
;
?>
<?php
if
(
!
empty
(
$method
->
return
))
:
?>
<tr>
<t
d
class=
"paramNameCol"
>
<?=
'return'
;
?>
</td
>
<t
h
class=
"paramNameCol"
>
<?=
'return'
;
?>
</th
>
<td
class=
"paramTypeCol"
>
<?=
$renderer
->
createTypeLink
(
$method
->
returnTypes
);
?>
</td>
<td
class=
"paramDescCol"
>
<?=
ApiMarkdown
::
process
(
$method
->
return
,
$type
);
?>
</td>
</tr>
<?php
endif
;
?>
<?php
foreach
(
$method
->
exceptions
as
$exception
=>
$description
)
:
?>
<tr>
<t
d
class=
"paramNameCol"
>
<?=
'throws'
?>
</td
>
<t
h
class=
"paramNameCol"
>
<?=
'throws'
?>
</th
>
<td
class=
"paramTypeCol"
>
<?=
$renderer
->
createTypeLink
(
$exception
)
?>
</td>
<td
class=
"paramDescCol"
>
<?=
ApiMarkdown
::
process
(
$description
,
$type
)
?>
</td>
</tr>
...
...
extensions/mongodb/Collection.php
View file @
6a193f38
...
...
@@ -107,12 +107,70 @@ class Collection extends Object
{
$parts
=
[];
foreach
(
$arguments
as
$argument
)
{
$parts
[]
=
is_scalar
(
$argument
)
?
$argument
:
Json
::
encode
(
$argument
);
$parts
[]
=
is_scalar
(
$argument
)
?
$argument
:
$this
->
encodeLogData
(
$argument
);
}
return
$this
->
getFullName
()
.
'.'
.
$command
.
'('
.
implode
(
', '
,
$parts
)
.
')'
;
}
/**
* Encodes complex log data into JSON format string.
* @param mixed $data raw data.
* @return string encoded data string.
*/
protected
function
encodeLogData
(
$data
)
{
return
json_encode
(
$this
->
processLogData
(
$data
));
}
/**
* Pre-processes the log data before sending it to `json_encode()`.
* @param mixed $data raw data.
* @return mixed the processed data.
*/
protected
function
processLogData
(
$data
)
{
if
(
is_object
(
$data
))
{
if
(
$data
instanceof
\MongoId
||
$data
instanceof
\MongoRegex
||
$data
instanceof
\MongoDate
||
$data
instanceof
\MongoInt32
||
$data
instanceof
\MongoInt64
||
$data
instanceof
\MongoTimestamp
)
{
$data
=
get_class
(
$data
)
.
'('
.
$data
->
__toString
()
.
')'
;
}
elseif
(
$data
instanceof
\MongoCode
)
{
$data
=
'MongoCode( '
.
$data
->
__toString
()
.
' )'
;
}
elseif
(
$data
instanceof
\MongoBinData
)
{
$data
=
'MongoBinData(...)'
;
}
elseif
(
$data
instanceof
\MongoDBRef
)
{
$data
=
'MongoDBRef(...)'
;
}
elseif
(
$data
instanceof
\MongoMinKey
||
$data
instanceof
\MongoMaxKey
)
{
$data
=
get_class
(
$data
);
}
else
{
$result
=
[];
foreach
(
$data
as
$name
=>
$value
)
{
$result
[
$name
]
=
$value
;
}
$data
=
$result
;
}
if
(
$data
===
[])
{
return
new
\stdClass
();
}
}
if
(
is_array
(
$data
))
{
foreach
(
$data
as
$key
=>
$value
)
{
if
(
is_array
(
$value
)
||
is_object
(
$value
))
{
$data
[
$key
]
=
$this
->
processLogData
(
$value
);
}
}
}
return
$data
;
}
/**
* Drops this collection.
* @throws Exception on failure.
* @return boolean whether the operation successful.
...
...
@@ -733,7 +791,13 @@ class Collection extends Object
$rawId
=
(
string
)
$rawId
;
}
}
return
new
\MongoId
(
$rawId
);
try
{
$mongoId
=
new
\MongoId
(
$rawId
);
}
catch
(
\MongoException
$e
)
{
// invalid id format
$mongoId
=
$rawId
;
}
return
$mongoId
;
}
/**
...
...
extensions/mongodb/README.md
View file @
6a193f38
...
...
@@ -184,6 +184,37 @@ $models = $provider->getModels();
```
Working with embedded documents
-------------------------------
This extension does not provide any special way to work with embedded documents (sub-documents).
General recommendation is avoiding it if possible.
For example: instead of:
```
{
content: "some content",
author: {
name: author1,
email: author1@domain.com
}
}
```
use following:
```
{
content: "some content",
author_name: author1,
author_email: author1@domain.com
}
```
Yii Model designed assuming single attribute is a scalar. Validation and attribute processing based on this suggestion.
Still any attribute can be an array of any depth and complexity, however you should handle its validation on your own.
Using GridFS
------------
...
...
extensions/mongodb/file/ActiveRecord.php
View file @
6a193f38
...
...
@@ -178,6 +178,16 @@ abstract class ActiveRecord extends \yii\mongodb\ActiveRecord
unset
(
$values
[
'file'
]);
}
if
(
isset
(
$newFileContent
)
||
isset
(
$newFile
))
{
$fileAssociatedAttributeNames
=
[
'filename'
,
'uploadDate'
,
'length'
,
'chunkSize'
,
'md5'
,
'file'
,
'newFileContent'
];
$values
=
array_merge
(
$this
->
getAttributes
(
null
,
$fileAssociatedAttributeNames
),
$values
);
$rows
=
$this
->
deleteInternal
();
$insertValues
=
$values
;
$insertValues
[
'_id'
]
=
$this
->
getAttribute
(
'_id'
);
...
...
extensions/twig/TwigSimpleFileLoader.php
View file @
6a193f38
...
...
@@ -33,8 +33,8 @@ class TwigSimpleFileLoader implements \Twig_LoaderInterface
/**
* Compare a file's freshness with previously stored timestamp
*
* @param
$name string
file name to check
* @param
$time int
timestamp to compare with
* @param
string $name
file name to check
* @param
integer $time
timestamp to compare with
* @return boolean true if file is still fresh and not changes, false otherwise
*/
public
function
isFresh
(
$name
,
$time
)
...
...
framework/base/Widget.php
View file @
6a193f38
...
...
@@ -31,7 +31,7 @@ class Widget extends Component implements ViewContextInterface
public
static
$counter
=
0
;
/**
* @var string the prefix to the automatically generated widget IDs.
* @see
[[getId()]]
* @see
getId()
*/
public
static
$autoIdPrefix
=
'w'
;
...
...
framework/console/controllers/AssetController.php
View file @
6a193f38
...
...
@@ -62,7 +62,7 @@ class AssetController extends Controller
*/
public
$targets
=
[];
/**
* @var string|call
back
JavaScript file compressor.
* @var string|call
able
JavaScript file compressor.
* If a string, it is treated as shell command template, which should contain
* placeholders {from} - source file name - and {to} - output file name.
* Otherwise, it is treated as PHP callback, which should perform the compression.
...
...
@@ -72,7 +72,7 @@ class AssetController extends Controller
*/
public
$jsCompressor
=
'java -jar compiler.jar --js {from} --js_output_file {to}'
;
/**
* @var string|call
back
CSS file compressor.
* @var string|call
able
CSS file compressor.
* If a string, it is treated as shell command template, which should contain
* placeholders {from} - source file name - and {to} - output file name.
* Otherwise, it is treated as PHP callback, which should perform the compression.
...
...
@@ -88,6 +88,7 @@ class AssetController extends Controller
*/
private
$_assetManager
=
[];
/**
* Returns the asset manager instance.
* @throws \yii\console\Exception on invalid configuration.
...
...
framework/rest/HttpBearerAuth.php
View file @
6a193f38
...
...
@@ -46,7 +46,7 @@ class HttpBearerAuth extends Component implements AuthInterface
*/
public
function
handleFailure
(
$response
)
{
$response
->
getHeaders
()
->
set
(
'WWW-Authenticate'
,
"B
asic
realm=
\"
{
$this
->
realm
}
\"
"
);
$response
->
getHeaders
()
->
set
(
'WWW-Authenticate'
,
"B
earer
realm=
\"
{
$this
->
realm
}
\"
"
);
throw
new
UnauthorizedHttpException
(
'You are requesting with an invalid access token.'
);
}
}
framework/web/User.php
View file @
6a193f38
...
...
@@ -525,7 +525,7 @@ class User extends Component
protected
function
renewAuthStatus
()
{
$session
=
Yii
::
$app
->
getSession
();
$id
=
$session
->
getHasSessionId
()
?
$session
->
get
(
$this
->
idParam
)
:
null
;
$id
=
$session
->
getHasSessionId
()
||
$session
->
getIsActive
()
?
$session
->
get
(
$this
->
idParam
)
:
null
;
if
(
$id
===
null
)
{
$identity
=
null
;
...
...
framework/widgets/DetailView.php
View file @
6a193f38
...
...
@@ -76,7 +76,7 @@ class DetailView extends Widget
*/
public
$attributes
;
/**
* @var string|call
back
the template used to render a single attribute. If a string, the token `{label}`
* @var string|call
able
the template used to render a single attribute. If a string, the token `{label}`
* and `{value}` will be replaced with the label and the value of the corresponding attribute.
* If a callback (e.g. an anonymous function), the signature must be as follows:
*
...
...
framework/widgets/ListView.php
View file @
6a193f38
...
...
@@ -25,7 +25,7 @@ class ListView extends BaseListView
*/
public
$itemOptions
=
[];
/**
* @var string|call
back
the name of the view for rendering each data item, or a callback (e.g. an anonymous function)
* @var string|call
able
the name of the view for rendering each data item, or a callback (e.g. an anonymous function)
* for rendering each data item. If it specifies a view name, the following variables will
* be available in the view:
*
...
...
tests/unit/extensions/mongodb/CollectionTest.php
View file @
6a193f38
...
...
@@ -419,4 +419,48 @@ class CollectionTest extends MongoDbTestCase
$this
->
assertNotEmpty
(
$result
);
$this
->
assertCount
(
2
,
$result
);
}
/**
* @depends testInsert
* @depends testFind
*/
public
function
testFindByNotObjectId
()
{
$collection
=
$this
->
getConnection
()
->
getCollection
(
'customer'
);
$data
=
[
'name'
=>
'customer 1'
,
'address'
=>
'customer 1 address'
,
];
$id
=
$collection
->
insert
(
$data
);
$cursor
=
$collection
->
find
([
'_id'
=>
(
string
)
$id
]);
$this
->
assertTrue
(
$cursor
instanceof
\MongoCursor
);
$row
=
$cursor
->
getNext
();
$this
->
assertEquals
(
$id
,
$row
[
'_id'
]);
$cursor
=
$collection
->
find
([
'_id'
=>
'fake'
]);
$this
->
assertTrue
(
$cursor
instanceof
\MongoCursor
);
$this
->
assertEquals
(
0
,
$cursor
->
count
());
}
/**
* @depends testInsert
*
* @see https://github.com/yiisoft/yii2/issues/2548
*/
public
function
testInsertMongoBin
()
{
$collection
=
$this
->
getConnection
()
->
getCollection
(
'customer'
);
$fileName
=
realpath
(
__DIR__
.
'/../../../../extensions/gii/assets/logo.png'
);
$data
=
[
'name'
=>
'customer 1'
,
'address'
=>
'customer 1 address'
,
'binData'
=>
new
\MongoBinData
(
file_get_contents
(
$fileName
),
2
),
];
$id
=
$collection
->
insert
(
$data
);
$this
->
assertTrue
(
$id
instanceof
\MongoId
);
$this
->
assertNotEmpty
(
$id
->
__toString
());
}
}
\ No newline at end of file
tests/unit/extensions/mongodb/file/ActiveRecordTest.php
View file @
6a193f38
...
...
@@ -248,6 +248,7 @@ class ActiveRecordTest extends MongoDbTestCase
$record2
=
CustomerFile
::
find
(
$record
->
_id
);
$this
->
assertEquals
(
$record
->
status
,
$record2
->
status
);
$this
->
assertEquals
(
file_get_contents
(
$updateFileName
),
$record2
->
getFileContent
());
$this
->
assertEquals
(
$record
->
tag
,
$record2
->
tag
);
}
/**
...
...
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