Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
f200debb
Commit
f200debb
authored
Aug 28, 2012
by
tim.plunkett
Browse files
Issue
#1760586
by tim.plunkett: Refactor and reorganize the tests.
parent
3e354810
Changes
67
Hide whitespace changes
Inline
Side-by-side
lib/Drupal/views/Tests/AnalyzeTest.php
View file @
f200debb
...
...
@@ -10,12 +10,12 @@
/**
* Tests the views analyze system.
*/
class
AnalyzeTest
extends
View
sSql
Test
{
class
AnalyzeTest
extends
ViewTest
Base
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Views Analyze'
,
'description'
=>
'Test the views analyze system.'
,
'description'
=>
'Test
s
the views analyze system.'
,
'group'
=>
'Views'
,
);
}
...
...
@@ -46,4 +46,5 @@ function testAnalyzeBasic() {
// This redirects the user back to the main views edit page.
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Ok'
));
}
}
lib/Drupal/views/Tests/BasicTest.php
View file @
f200debb
...
...
@@ -10,15 +10,22 @@
/**
* Basic test class for Views query builder tests.
*/
class
BasicTest
extends
ViewsSchemaTestBase
{
class
BasicTest
extends
ViewTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Basic query test'
,
'name'
=>
'Basic query test
s
'
,
'description'
=>
'A basic query test for Views.'
,
'group'
=>
'Views'
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
/**
* Tests a trivial result set.
*/
...
...
@@ -177,4 +184,5 @@ public function testSimpleArgument() {
'views_test_age'
=>
'age'
,
));
}
}
lib/Drupal/views/Tests/Comment/ArgumentUserUIDTest.php
0 → 100644
View file @
f200debb
<?php
/**
* @file
* Definition of Drupal\views\Tests\Comment\ArgumentUserUIDTest.
*/
namespace
Drupal\views\Tests\Comment
;
use
Drupal\views\View
;
/**
* Tests the argument_comment_user_uid handler.
*/
class
ArgumentUserUIDTest
extends
CommentTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Comment: User UID Argument'
,
'description'
=>
'Tests the user posted or commented argument handler.'
,
'group'
=>
'Views Modules'
,
);
}
function
testCommentUserUIDTest
()
{
$view
=
$this
->
view_comment_user_uid
();
$this
->
executeView
(
$view
,
array
(
$this
->
account
->
uid
));
$result_set
=
array
(
array
(
'nid'
=>
$this
->
node_user_posted
->
nid
,
),
array
(
'nid'
=>
$this
->
node_user_commented
->
nid
,
),
);
$this
->
column_map
=
array
(
'nid'
=>
'nid'
);
$this
->
assertIdenticalResultset
(
$view
,
$result_set
,
$this
->
column_map
);
}
}
lib/Drupal/views/Tests/Comment/
ArgumentCommentUserUidTest
.php
→
lib/Drupal/views/Tests/Comment/
CommentTestBase
.php
View file @
f200debb
...
...
@@ -2,75 +2,40 @@
/**
* @file
* Definition of Drupal\views\Tests\Comment\
ArgumentCommentUserUidTest
.
* Definition of Drupal\views\Tests\Comment\
CommentTestBase
.
*/
namespace
Drupal\views\Tests\Comment
;
use
Drupal\views\Tests\View
sSql
Test
;
use
Drupal\views\Tests\ViewTest
Base
;
use
Drupal\views\View
;
/**
* Tests the argument_comment_user_uid handler.
*/
class
ArgumentCommentUserUidTest
extends
ViewsSqlTest
{
protected
$profile
=
'standard'
;
abstract
class
CommentTestBase
extends
ViewTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Tests handler argument_comment_user_uid'
,
'description'
=>
'Tests the user posted or commented argument handler'
,
'group'
=>
'Views Modules'
,
);
}
/**
* Post comment.
*
* @param $node
* Node to post comment on.
* @param $comment
* Comment to save
*/
function
postComment
(
$node
,
$comment
=
array
())
{
$comment
+=
array
(
'uid'
=>
$this
->
loggedInUser
->
uid
,
'nid'
=>
$node
->
nid
,
'cid'
=>
''
,
'pid'
=>
''
,
);
return
entity_create
(
'comment'
,
$comment
)
->
save
();
}
protected
$profile
=
'standard'
;
function
setUp
()
{
parent
::
setUp
();
// Add two users, create a node with the user1 as author and another node
with user2 as author.
// For the second node add a comment from user1.
// Add two users, create a node with the user1 as author and another node
//
with user2 as author.
For the second node add a comment from user1.
$this
->
account
=
$this
->
drupalCreateUser
();
$this
->
account2
=
$this
->
drupalCreateUser
();
$this
->
drupalLogin
(
$this
->
account
);
$this
->
node_user_posted
=
$this
->
drupalCreateNode
();
$this
->
node_user_commented
=
$this
->
drupalCreateNode
(
array
(
'uid'
=>
$this
->
account2
->
uid
));
$this
->
postComment
(
$this
->
node_user_commented
);
}
function
testCommentUserUidTest
()
{
$view
=
$this
->
view_comment_user_uid
();
$this
->
executeView
(
$view
,
array
(
$this
->
account
->
uid
));
$resultset
=
array
(
array
(
'nid'
=>
$this
->
node_user_posted
->
nid
,
),
array
(
'nid'
=>
$this
->
node_user_commented
->
nid
,
),
$comment
=
array
(
'uid'
=>
$this
->
loggedInUser
->
uid
,
'nid'
=>
$this
->
node_user_commented
->
nid
,
'cid'
=>
''
,
'pid'
=>
''
,
);
$this
->
column_map
=
array
(
'nid'
=>
'nid'
);
debug
(
$view
->
result
);
$this
->
assertIdenticalResultset
(
$view
,
$resultset
,
$this
->
column_map
);
entity_create
(
'comment'
,
$comment
)
->
save
();
}
function
view_comment_user_uid
()
{
...
...
@@ -110,4 +75,5 @@ function view_comment_user_uid() {
return
$view
;
}
}
lib/Drupal/views/Tests/Comment/Filter
Comment
UserU
id
Test.php
→
lib/Drupal/views/Tests/Comment/FilterUserU
ID
Test.php
View file @
f200debb
...
...
@@ -2,21 +2,24 @@
/**
* @file
* Definition of Drupal\views\Tests\Comment\Filter
Comment
UserU
id
Test.
* Definition of Drupal\views\Tests\Comment\FilterUserU
ID
Test.
*/
namespace
Drupal\views\Tests\Comment
;
use
Drupal\views\View
;
/**
* Tests the filter_comment_user_uid handler.
*
* The actual stuff is done in the parent class.
*/
class
FilterCommentUserUidTest
extends
ArgumentCommentUserUidTest
{
class
FilterUserUIDTest
extends
CommentTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'
Tests handler filter_comment_user_uid
'
,
'description'
=>
'Tests the user posted or commented filter handler'
,
'name'
=>
'
Comment: User UID Filter
'
,
'description'
=>
'Tests the user posted or commented filter handler
.
'
,
'group'
=>
'Views Modules'
,
);
}
...
...
@@ -40,4 +43,21 @@ function view_comment_user_uid() {
return
$view
;
}
function
testCommentUserUIDTest
()
{
$view
=
$this
->
view_comment_user_uid
();
$this
->
executeView
(
$view
,
array
(
$this
->
account
->
uid
));
$result_set
=
array
(
array
(
'nid'
=>
$this
->
node_user_posted
->
nid
,
),
array
(
'nid'
=>
$this
->
node_user_commented
->
nid
,
),
);
$this
->
column_map
=
array
(
'nid'
=>
'nid'
);
$this
->
assertIdenticalResultset
(
$view
,
$result_set
,
$this
->
column_map
);
}
}
lib/Drupal/views/Tests/Field/ApiDataTest.php
View file @
f200debb
...
...
@@ -10,7 +10,7 @@
/**
* Test the produced views_data.
*/
class
ApiDataTest
extends
Api
TestBase
{
class
ApiDataTest
extends
Field
TestBase
{
/**
* Stores the fields for this test case.
*/
...
...
@@ -18,8 +18,8 @@ class ApiDataTest extends ApiTestBase {
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field
api
: Views Data'
,
'description'
=>
'Tests the
f
ield
api v
iews data.'
,
'name'
=>
'Field: Views Data'
,
'description'
=>
'Tests the
F
ield
V
iews data.'
,
'group'
=>
'Views Modules'
,
);
}
...
...
lib/Drupal/views/Tests/Field/
Api
TestBase.php
→
lib/Drupal/views/Tests/Field/
Field
TestBase.php
View file @
f200debb
...
...
@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\views\Test\Field\
ApiTestHelper
.
* Definition of Drupal\views\Test\Field\
FieldTestBase
.
*/
/**
...
...
@@ -18,12 +18,13 @@
namespace
Drupal\views\Tests\Field
;
use
Drupal\views\Tests\View
sSql
Test
;
use
Drupal\views\Tests\ViewTest
Base
;
/**
* Provides some helper methods for testing fieldapi integration into views.
*/
abstract
class
ApiTestBase
extends
ViewsSqlTest
{
abstract
class
FieldTestBase
extends
ViewTestBase
{
protected
$profile
=
'standard'
;
/**
...
...
@@ -71,4 +72,5 @@ function clearViewsCaches() {
$cache
=
NULL
;
$recursion_protection
=
NULL
;
}
}
lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.php
View file @
f200debb
...
...
@@ -17,13 +17,13 @@
* Check locale:disabled, locale:enabled and locale:enabled with another language
* Check revisions
*/
class
HandlerFieldFieldTest
extends
Api
TestBase
{
class
HandlerFieldFieldTest
extends
Field
TestBase
{
public
$nodes
;
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field
api
: Field handler'
,
'description'
=>
'Tests the field itself of the
f
ield
api
integration'
,
'name'
=>
'Field: Field handler'
,
'description'
=>
'Tests the field itself of the
F
ield integration
.
'
,
'group'
=>
'Views Modules'
);
}
...
...
lib/Drupal/views/Tests/GlossaryTest.php
View file @
f200debb
...
...
@@ -10,11 +10,11 @@
/**
* Tests glossary view ( summary of arguments ).
*/
class
GlossaryTest
extends
View
sSql
Test
{
class
GlossaryTest
extends
ViewTest
Base
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Glossary
T
est'
,
'name'
=>
'Glossary
t
est
s
'
,
'description'
=>
'Tests glossary functionality of views.'
,
'group'
=>
'Views'
,
);
...
...
@@ -56,4 +56,5 @@ public function testGlossaryView() {
$this
->
assertEqual
(
$nodes_per_char
[
$item
->
title_truncated
],
$item
->
num_records
);
}
}
}
lib/Drupal/views/Tests/Handler/AreaTextTest.php
View file @
f200debb
...
...
@@ -7,14 +7,12 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the text area handler.
*
* @see views_handler_area_text
*/
class
AreaTextTest
extends
ViewsSchema
TestBase
{
class
AreaTextTest
extends
Handler
TestBase
{
public
static
function
getInfo
()
{
return
array
(
...
...
@@ -24,6 +22,12 @@ public static function getInfo() {
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
public
function
testAreaText
()
{
$view
=
$this
->
getBasicView
();
...
...
lib/Drupal/views/Tests/Handler/ArgumentNullTest.php
View file @
f200debb
...
...
@@ -7,12 +7,11 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the core Drupal\views\Plugin\views\argument\Null handler.
*/
class
ArgumentNullTest
extends
ViewsSchemaTestBase
{
class
ArgumentNullTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Argument: Null'
,
...
...
@@ -21,6 +20,12 @@ public static function getInfo() {
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
function
viewsData
()
{
$data
=
parent
::
viewsData
();
$data
[
'views_test'
][
'id'
][
'argument'
][
'id'
]
=
'null'
;
...
...
lib/Drupal/views/Tests/Handler/ArgumentStringTest.php
View file @
f200debb
...
...
@@ -7,13 +7,12 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSqlTest
;
use
Drupal\views\View
;
/**
* Tests the core Drupal\views\Plugin\views\argument\String handler.
*/
class
ArgumentStringTest
extends
ViewsSqlTest
{
class
ArgumentStringTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Argument: String'
,
...
...
lib/Drupal/views/Tests/Handler/FieldBooleanTest.php
View file @
f200debb
...
...
@@ -7,12 +7,11 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the core Drupal\views\Plugin\views\field\Boolean handler.
*/
class
FieldBooleanTest
extends
ViewsSchemaTestBase
{
class
FieldBooleanTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field: Boolean'
,
...
...
@@ -21,6 +20,12 @@ public static function getInfo() {
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
function
dataSet
()
{
// Use default dataset but remove the age from john and paul
$data
=
parent
::
dataSet
();
...
...
@@ -77,4 +82,5 @@ public function testFieldBoolean() {
$this
->
assertEqual
(
t
(
'Test-True'
),
$view
->
field
[
'age'
]
->
advanced_render
(
$view
->
result
[
1
]));
}
}
lib/Drupal/views/Tests/Handler/FieldCounterTest.php
View file @
f200debb
...
...
@@ -7,12 +7,11 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the Drupal\views\Plugin\views\field\Counter handler.
*/
class
FieldCounterTest
extends
ViewsSchemaTestBase
{
class
FieldCounterTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field: Counter'
,
...
...
@@ -21,6 +20,12 @@ public static function getInfo() {
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
function
testSimple
()
{
$view
=
$this
->
getBasicView
();
$view
->
display
[
'default'
]
->
handler
->
override_option
(
'fields'
,
array
(
...
...
@@ -71,4 +76,5 @@ function testSimple() {
// @TODO: Write tests for pager.
function
testPager
()
{
}
}
lib/Drupal/views/Tests/Handler/FieldCustomTest.php
View file @
f200debb
...
...
@@ -7,12 +7,11 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the core Drupal\views\Plugin\views\field\Custom handler.
*/
class
FieldCustomTest
extends
ViewsSchemaTestBase
{
class
FieldCustomTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field: Custom'
,
...
...
@@ -21,6 +20,12 @@ public static function getInfo() {
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
function
viewsData
()
{
$data
=
parent
::
viewsData
();
$data
[
'views_test'
][
'name'
][
'field'
][
'id'
]
=
'custom'
;
...
...
@@ -48,4 +53,5 @@ public function testFieldCustom() {
$this
->
assertEqual
(
$random
,
$view
->
style_plugin
->
get_field
(
0
,
'name'
));
}
}
lib/Drupal/views/Tests/Handler/FieldDateTest.php
View file @
f200debb
...
...
@@ -7,12 +7,11 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the core Drupal\views\Plugin\views\field\Date handler.
*/
class
FieldDateTest
extends
ViewsSchemaTestBase
{
class
FieldDateTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field: Date'
,
...
...
@@ -21,6 +20,12 @@ public static function getInfo() {
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
function
viewsData
()
{
$data
=
parent
::
viewsData
();
$data
[
'views_test'
][
'created'
][
'field'
][
'id'
]
=
'date'
;
...
...
@@ -88,4 +93,5 @@ protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
$this
->
assertEqual
(
$expected_result
,
$actual_result
,
$message
);
}
}
}
lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php
View file @
f200debb
...
...
@@ -7,22 +7,27 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the core Drupal\views\Plugin\views\field\FileSize handler.
*
* @see CommonXssUnitTest
*/
class
FieldFileSizeTest
extends
ViewsSchemaTestBase
{
class
FieldFileSizeTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field:
f
ile
_
size'
,
'name'
=>
'Field:
F
ile
size'
,
'description'
=>
'Test the core Drupal\views\Plugin\views\field\FileSize handler.'
,
'group'
=>
'Views Handlers'
,
);
}
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
}
function
dataSet
()
{
$data
=
parent
::
dataSet
();
$data
[
0
][
'age'
]
=
0
;
...
...
@@ -65,4 +70,5 @@ public function testFieldFileSize() {
$this
->
assertEqual
(
$view
->
field
[
'age'
]
->
advanced_render
(
$view
->
result
[
2
]),
1000
);
$this
->
assertEqual
(
$view
->
field
[
'age'
]
->
advanced_render
(
$view
->
result
[
3
]),
10000
);
}
}
lib/Drupal/views/Tests/Handler/FieldTest.php
View file @
f200debb
...
...
@@ -7,14 +7,13 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the generic field handler
*
* @see views_handler_field
*/
class
FieldTest
extends
ViewsSchemaTestBase
{
class
FieldTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field'
,
...
...
@@ -25,6 +24,9 @@ public static function getInfo() {
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
enableViewsTestModule
();
$this
->
column_map
=
array
(
'views_test_name'
=>
'name'
,
);
...
...
lib/Drupal/views/Tests/Handler/FieldUrlTest.php
View file @
f200debb
...
...
@@ -7,19 +7,25 @@
namespace
Drupal\views\Tests\Handler
;
use
Drupal\views\Tests\ViewsSchemaTestBase
;
/**
* Tests the core Drupal\views\Plugin\views\field\Url handler.
*/
class
FieldUrlTest
extends
ViewsSchemaTestBase
{
class
FieldUrlTest
extends
HandlerTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field: U
rl
'
,
'name'
=>
'Field: U
RL
'
,