Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pquery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
pquery
Commits
31aaff40
Commit
31aaff40
authored
Nov 07, 2011
by
Taddes Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some basic unit tests.
parent
9182a8e1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
8 deletions
+52
-8
pquery.array.php
pquery.array.php
+2
-0
pquery.php
pquery.php
+6
-3
test/test_array.php
test/test_array.php
+37
-2
test/test_pquery.php
test/test_pquery.php
+1
-1
test/test_sql.php
test/test_sql.php
+3
-1
test/test_template.php
test/test_template.php
+3
-1
No files found.
pquery.array.php
View file @
31aaff40
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
* @todo Documentation
* @todo Documentation
*/
*/
class
pQueryArray
extends
pQuery
implements
pQueryExtension
{
class
pQueryArray
extends
pQuery
implements
pQueryExtension
{
static
$accepts
=
array
(
'array'
);
/**
/**
* Get the value of an array alement at the given index.
* Get the value of an array alement at the given index.
*
*
...
...
pquery.php
View file @
31aaff40
...
@@ -219,13 +219,16 @@ class pQuery {
...
@@ -219,13 +219,16 @@ class pQuery {
if
(
isset
(
$accepts
[
$type
])
)
{
if
(
isset
(
$accepts
[
$type
])
)
{
$convert_method
=
$accepts
[
$type
];
$convert_method
=
$accepts
[
$type
];
if
(
!
method_exists
(
$this
,
$convert_method
)
)
if
(
!
method_exists
(
$this
,
$convert_method
)
)
{
return
self
::
error
(
'Plugin "%s" has no conversion method "%s".'
,
$class_name
,
$convert_method
);
return
self
::
error
(
'Plugin "%s" has no conversion method "%s".'
,
$class_name
,
$convert_method
);
}
$result
=
$this
->
$convert_method
(
$variable
);
$result
=
$this
->
$convert_method
(
$variable
);
$result
===
null
||
$this
->
variable
=
$result
;
$result
===
null
||
$this
->
variable
=
$result
;
}
else
if
(
!
in_array
(
$type
,
$accepts
)
)
{
}
else
if
(
!
in_array
(
$type
,
$accepts
)
)
{
return
self
::
error
(
'Variable type "%s" is not accepted by class "%s".'
,
$type
,
$class_name
);
return
self
::
error
(
'Variable type "%s" is not accepted by class "%s".'
,
$type
,
$class_name
);
}
}
}
}
...
...
test/test_array.php
View file @
31aaff40
<?php
<?php
__p
::
load_plugin
(
'array'
);
class
pQueryArrayTest
extends
UnitTestCase
{
class
pQueryArrayTest
extends
UnitTestCase
{
var
$variable
;
var
$arr
;
function
__construct
()
{
function
__construct
()
{
$this
->
UnitTestCase
(
'pQuery array plugin test'
);
parent
::
__construct
(
'pQuery array plugin'
);
}
function
setUp
()
{
$this
->
variable
=
array
(
'test'
);
$this
->
arr
=
_arr
(
$this
->
variable
);
}
function
test_constructor
()
{
$this
->
assertIsA
(
$this
->
arr
,
'pQueryArray'
,
'constructor does not return pQueryArray object.'
);
$this
->
assertEqual
(
$this
->
arr
->
variable
,
$this
->
variable
,
'variable is not set correctly.'
);
}
function
test_get_simple
()
{
$this
->
assertEqual
(
$this
->
arr
->
get
(
0
),
$this
->
variable
[
0
]);
}
function
test_get_non_existent
()
{
$this
->
assertNull
(
$this
->
arr
->
get
(
count
(
$this
->
variable
)),
'non-existent index should yield NULL.'
);
}
function
test_is_empty_empty
()
{
$this
->
assertTrue
(
_arr
(
array
())
->
is_empty
());
}
function
test_is_empty_non_empty
()
{
$this
->
assertFalse
(
$this
->
arr
->
is_empty
());
}
}
function
test_
()
{
function
test_reverse
()
{
$orginal
=
range
(
1
,
4
);
$reverse
=
range
(
4
,
1
,
-
1
);
$arr
=
_arr
(
$orginal
);
$this
->
assertEqual
(
$arr
->
reverse
()
->
variable
,
$reverse
,
'reverse is not really reverse...'
);
}
}
}
}
...
...
test/test_pquery.php
View file @
31aaff40
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
class
pQueryTest
extends
UnitTestCase
{
class
pQueryTest
extends
UnitTestCase
{
function
__construct
()
{
function
__construct
()
{
$this
->
UnitTestCase
(
'pQuery base test
'
);
parent
::
__construct
(
'pQuery base
'
);
}
}
function
test_
()
{
function
test_
()
{
...
...
test/test_sql.php
View file @
31aaff40
<?php
<?php
__p
::
load_plugin
(
'sql'
);
class
pQuerySqlTest
extends
UnitTestCase
{
class
pQuerySqlTest
extends
UnitTestCase
{
function
__construct
()
{
function
__construct
()
{
$this
->
UnitTestCase
(
'pQuery MySQL plugin test
'
);
parent
::
__construct
(
'pQuery MySQL plugin
'
);
}
}
function
test_
()
{
function
test_
()
{
...
...
test/test_template.php
View file @
31aaff40
<?php
<?php
__p
::
load_plugin
(
'template'
);
class
pQueryTemplateTest
extends
UnitTestCase
{
class
pQueryTemplateTest
extends
UnitTestCase
{
function
__construct
()
{
function
__construct
()
{
$this
->
UnitTestCase
(
'pQuery template plugin test
'
);
parent
::
__construct
(
'pQuery template plugin
'
);
}
}
function
test_
()
{
function
test_
()
{
...
...
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