Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
storm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
afi
storm
Commits
facf291b
Commit
facf291b
authored
Sep 20, 2018
by
Patrick Barroca
🐧
1
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'perfs_phpunit' into 'master'
Perfs phpunit See merge request
!22
parents
84f4fb2e
ff2fc936
Pipeline
#5418
canceled with stage
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
Abstract.php
src/Storm/Model/Abstract.php
+18
-2
Db.php
src/Storm/Model/PersistenceStrategy/Db.php
+1
-1
LoaderTest.php
tests/Storm/Test/LoaderTest.php
+1
-1
No files found.
src/Storm/Model/Abstract.php
View file @
facf291b
...
...
@@ -28,7 +28,13 @@ abstract class Storm_Model_Abstract {
/**
* @var array
*/
protected
static
$_loaders
=
array
();
protected
static
$_loaders
=
[];
protected
static
$_method_prefixes
=
[
'get'
=>
3
,
'set'
=>
3
,
'add'
=>
3
,
'remove'
=>
6
,
'has'
=>
3
,
'numberOf'
=>
8
];
/**
* @var string
...
...
@@ -665,6 +671,16 @@ abstract class Storm_Model_Abstract {
}
protected
function
_methodMatch
(
$method
)
{
foreach
(
static
::
$_method_prefixes
as
$prefix
=>
$length
)
{
if
(
substr
(
$method
,
0
,
$length
)
==
$prefix
)
return
[
1
=>
$prefix
,
2
=>
substr
(
$method
,
$length
)];
}
return
null
;
}
/**
* See __call
*
...
...
@@ -678,7 +694,7 @@ abstract class Storm_Model_Abstract {
* @throws Exception
*/
public
function
perform
(
$method
,
$args
=
[])
{
if
(
!
preg_match
(
'/(get|set|add|remove|has|numberOf)(\w+)/'
,
$method
,
$matches
))
{
if
(
!
$matches
=
$this
->
_methodMatch
(
$method
))
{
throw
new
Storm_Model_Exception
(
'Tried to call unknown method '
.
get_class
(
$this
)
.
'::'
.
$method
);
}
...
...
src/Storm/Model/PersistenceStrategy/Db.php
View file @
facf291b
...
...
@@ -105,7 +105,7 @@ class Storm_Model_PersistenceStrategy_Db extends Storm_Model_PersistenceStrategy
return
0
;
$select
->
from
(
$this
->
getTable
(),
[
sprintf
(
'count(
%s) as numberof'
,
$this
->
_loader
->
getIdField
()
)]);
[
sprintf
(
'count(
*) as numberof'
)]);
$rows
=
$this
->
getTable
()
->
fetchAll
(
$select
)
->
toArray
();
return
$rows
[
0
][
'numberof'
];
}
...
...
tests/Storm/Test/LoaderTest.php
View file @
facf291b
...
...
@@ -52,7 +52,7 @@ class Storm_Test_LoaderTest extends Storm_Test_ModelTestCase {
public
function
countByWithWhereShouldBuildRightSQL
()
{
$select
=
Storm_Test_ObjectWrapper
::
mock
()
->
whenCalled
(
'from'
)
->
with
(
$this
->
_table
,
array
(
'count(id) as numberof'
)
)
->
with
(
$this
->
_table
,
[
'count(*) as numberof'
]
)
->
answers
(
null
)
->
whenCalled
(
'where'
)
...
...
Ghislain Loas
@gloas
mentioned in merge request
opacce!2874 (merged)
·
Nov 12, 2018
mentioned in merge request
opacce!2874 (merged)
mentioned in merge request opacce!2874
Toggle commit list
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