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
0699eaad
Commit
0699eaad
authored
Jan 17, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test breaks
parent
53e96b29
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
16 deletions
+68
-16
Customer.php
tests/unit/data/ar/Customer.php
+6
-5
CustomerQuery.php
tests/unit/data/ar/CustomerQuery.php
+16
-0
Customer.php
tests/unit/data/ar/mongodb/Customer.php
+7
-4
CustomerQuery.php
tests/unit/data/ar/mongodb/CustomerQuery.php
+16
-0
ArticleIndex.php
tests/unit/data/ar/sphinx/ArticleIndex.php
+7
-7
ArticleIndexQuery.php
tests/unit/data/ar/sphinx/ArticleIndexQuery.php
+16
-0
No files found.
tests/unit/data/ar/Customer.php
View file @
0699eaad
<?php
<?php
namespace
yiiunit\data\ar
;
namespace
yiiunit\data\ar
;
use
yii\db\ActiveQuery
;
use
yiiunit\framework\db\ActiveRecordTest
;
use
yiiunit\framework\db\ActiveRecordTest
;
/**
/**
...
@@ -29,15 +30,15 @@ class Customer extends ActiveRecord
...
@@ -29,15 +30,15 @@ class Customer extends ActiveRecord
return
$this
->
hasMany
(
Order
::
className
(),
[
'customer_id'
=>
'id'
])
->
orderBy
(
'id'
);
return
$this
->
hasMany
(
Order
::
className
(),
[
'customer_id'
=>
'id'
])
->
orderBy
(
'id'
);
}
}
public
static
function
active
(
$query
)
{
$query
->
andWhere
(
'status=1'
);
}
public
function
afterSave
(
$insert
)
public
function
afterSave
(
$insert
)
{
{
ActiveRecordTest
::
$afterSaveInsert
=
$insert
;
ActiveRecordTest
::
$afterSaveInsert
=
$insert
;
ActiveRecordTest
::
$afterSaveNewRecord
=
$this
->
isNewRecord
;
ActiveRecordTest
::
$afterSaveNewRecord
=
$this
->
isNewRecord
;
parent
::
afterSave
(
$insert
);
parent
::
afterSave
(
$insert
);
}
}
public
static
function
createQuery
()
{
return
new
CustomerQuery
([
'modelClass'
=>
get_called_class
()]);
}
}
}
tests/unit/data/ar/CustomerQuery.php
0 → 100644
View file @
0699eaad
<?php
namespace
yiiunit\data\ar
;
use
yii\db\ActiveQuery
;
/**
* CustomerQuery
*/
class
CustomerQuery
extends
ActiveQuery
{
public
static
function
active
(
$query
)
{
$query
->
andWhere
(
'status=1'
);
}
}
\ No newline at end of file
tests/unit/data/ar/mongodb/Customer.php
View file @
0699eaad
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
namespace
yiiunit\data\ar\mongodb
;
namespace
yiiunit\data\ar\mongodb
;
use
yii\mongodb\ActiveQuery
;
class
Customer
extends
ActiveRecord
class
Customer
extends
ActiveRecord
{
{
public
static
function
collectionName
()
public
static
function
collectionName
()
...
@@ -20,13 +22,13 @@ class Customer extends ActiveRecord
...
@@ -20,13 +22,13 @@ class Customer extends ActiveRecord
];
];
}
}
public
static
function
activeOnly
(
$query
)
public
function
getOrders
(
)
{
{
$query
->
andWhere
([
'status'
=>
2
]);
return
$this
->
hasMany
(
CustomerOrder
::
className
(),
[
'customer_id'
=>
'_id'
]);
}
}
public
function
getOrders
()
public
static
function
createQuery
()
{
{
return
$this
->
hasMany
(
CustomerOrder
::
className
(),
[
'customer_id'
=>
'_id'
]);
return
new
CustomerQuery
([
'modelClass'
=>
get_called_class
()
]);
}
}
}
}
\ No newline at end of file
tests/unit/data/ar/mongodb/CustomerQuery.php
0 → 100644
View file @
0699eaad
<?php
namespace
yiiunit\data\ar\mongodb
;
use
yii\mongodb\ActiveQuery
;
/**
* CustomerQuery
*/
class
CustomerQuery
extends
ActiveQuery
{
public
static
function
activeOnly
(
$query
)
{
$query
->
andWhere
([
'status'
=>
2
]);
}
}
\ No newline at end of file
tests/unit/data/ar/sphinx/ArticleIndex.php
View file @
0699eaad
<?php
<?php
namespace
yiiunit\data\ar\sphinx
;
namespace
yiiunit\data\ar\sphinx
;
use
yii\
db\ActiveRelation
;
use
yii\
sphinx\ActiveQuery
;
class
ArticleIndex
extends
ActiveRecord
class
ArticleIndex
extends
ActiveRecord
{
{
...
@@ -13,11 +12,6 @@ class ArticleIndex extends ActiveRecord
...
@@ -13,11 +12,6 @@ class ArticleIndex extends ActiveRecord
return
'yii2_test_article_index'
;
return
'yii2_test_article_index'
;
}
}
public
static
function
favoriteAuthor
(
$query
)
{
$query
->
andWhere
(
'author_id=1'
);
}
public
function
getSource
()
public
function
getSource
()
{
{
return
$this
->
hasOne
(
ArticleDb
::
className
(),
[
'id'
=>
'id'
]);
return
$this
->
hasOne
(
ArticleDb
::
className
(),
[
'id'
=>
'id'
]);
...
@@ -32,4 +26,9 @@ class ArticleIndex extends ActiveRecord
...
@@ -32,4 +26,9 @@ class ArticleIndex extends ActiveRecord
{
{
return
$this
->
source
->
content
;
return
$this
->
source
->
content
;
}
}
public
static
function
createQuery
()
{
return
new
ArticleIndexQuery
([
'modelClass'
=>
get_called_class
()]);
}
}
}
\ No newline at end of file
tests/unit/data/ar/sphinx/ArticleIndexQuery.php
0 → 100644
View file @
0699eaad
<?php
namespace
yiiunit\data\ar\sphinx
;
use
yii\sphinx\ActiveQuery
;
/**
* ArticleIndexQuery
*/
class
ArticleIndexQuery
extends
ActiveQuery
{
public
static
function
favoriteAuthor
(
$query
)
{
$query
->
andWhere
(
'author_id=1'
);
}
}
\ 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