Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
2915f8cc
Commit
2915f8cc
authored
Sep 02, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unittests for analysis
parent
6e63f64a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
555 additions
and
0 deletions
+555
-0
tests/Solarium/ClientTest.php
tests/Solarium/ClientTest.php
+12
-0
tests/Solarium/Query/AnalysisTest.php
tests/Solarium/Query/AnalysisTest.php
+6
-0
tests/Solarium/Result/Analysis/DocumentTest.php
tests/Solarium/Result/Analysis/DocumentTest.php
+114
-0
tests/Solarium/Result/Analysis/FieldTest.php
tests/Solarium/Result/Analysis/FieldTest.php
+98
-0
tests/Solarium/Result/Analysis/ItemTest.php
tests/Solarium/Result/Analysis/ItemTest.php
+104
-0
tests/Solarium/Result/Analysis/ListTest.php
tests/Solarium/Result/Analysis/ListTest.php
+78
-0
tests/Solarium/Result/Analysis/TypesTest.php
tests/Solarium/Result/Analysis/TypesTest.php
+143
-0
No files found.
tests/Solarium/ClientTest.php
View file @
2915f8cc
...
@@ -617,6 +617,18 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
...
@@ -617,6 +617,18 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
$observer
->
moreLikeThis
(
$query
);
$observer
->
moreLikeThis
(
$query
);
}
}
public
function
testAnalyze
()
{
$query
=
new
Solarium_Query_Analysis_Field
();
$observer
=
$this
->
getMock
(
'Solarium_Client'
,
array
(
'execute'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'execute'
)
->
with
(
$this
->
equalTo
(
$query
));
$observer
->
analyze
(
$query
);
}
public
function
testCreateQuery
()
public
function
testCreateQuery
()
{
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
...
...
tests/Solarium/Query/AnalysisTest.php
View file @
2915f8cc
...
@@ -47,6 +47,12 @@ class Solarium_Query_AnalysisTest extends PHPUnit_Framework_TestCase
...
@@ -47,6 +47,12 @@ class Solarium_Query_AnalysisTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$querystring
,
$this
->
_query
->
getQuery
());
$this
->
assertEquals
(
$querystring
,
$this
->
_query
->
getQuery
());
}
}
public
function
testSetAndGetQueryWithBind
()
{
$this
->
_query
->
setQuery
(
'id:%1%'
,
array
(
678
));
$this
->
assertEquals
(
'id:678'
,
$this
->
_query
->
getQuery
());
}
public
function
testSetAndGetShowMatch
()
public
function
testSetAndGetShowMatch
()
{
{
$show
=
true
;
$show
=
true
;
...
...
tests/Solarium/Result/Analysis/DocumentTest.php
0 → 100644
View file @
2915f8cc
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class
Solarium_Result_Analysis_DocumentTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Analysis_Document
*/
protected
$_result
;
protected
$_items
;
public
function
setUp
()
{
$this
->
_items
=
array
(
'key1'
=>
'dummy1'
,
'key2'
=>
'dummy2'
,
'key3'
=>
'dummy3'
);
$this
->
_result
=
new
Solarium_Result_Analysis_DocumentDummy
(
1
,
12
,
$this
->
_items
);
}
public
function
testGetDocuments
()
{
$this
->
assertEquals
(
$this
->
_items
,
$this
->
_result
->
getDocuments
());
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
_items
),
count
(
$this
->
_result
));
}
public
function
testIterator
()
{
$docs
=
array
();
foreach
(
$this
->
_result
AS
$key
=>
$doc
)
{
$docs
[
$key
]
=
$doc
;
}
$this
->
assertEquals
(
$this
->
_items
,
$docs
);
}
public
function
testGetStatus
()
{
$this
->
assertEquals
(
1
,
$this
->
_result
->
getStatus
()
);
}
public
function
testGetQueryTime
()
{
$this
->
assertEquals
(
12
,
$this
->
_result
->
getQueryTime
()
);
}
public
function
testGetDocument
()
{
$this
->
assertEquals
(
$this
->
_items
[
'key2'
],
$this
->
_result
->
getDocument
(
'key2'
)
);
}
public
function
testGetInvalidDocument
()
{
$this
->
assertEquals
(
null
,
$this
->
_result
->
getDocument
(
'invalidkey'
)
);
}
}
class
Solarium_Result_Analysis_DocumentDummy
extends
Solarium_Result_Analysis_Document
{
protected
$_parsed
=
true
;
public
function
__construct
(
$status
,
$queryTime
,
$items
)
{
$this
->
_items
=
$items
;
$this
->
_queryTime
=
$queryTime
;
$this
->
_status
=
$status
;
}
}
\ No newline at end of file
tests/Solarium/Result/Analysis/FieldTest.php
0 → 100644
View file @
2915f8cc
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class
Solarium_Result_Analysis_FieldTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Analysis_Field
*/
protected
$_result
;
protected
$_items
;
public
function
setUp
()
{
$this
->
_items
=
array
(
'key1'
=>
'dummy1'
,
'key2'
=>
'dummy2'
,
'key3'
=>
'dummy3'
);
$this
->
_result
=
new
Solarium_Result_Analysis_FieldDummy
(
1
,
12
,
$this
->
_items
);
}
public
function
testGetLists
()
{
$this
->
assertEquals
(
$this
->
_items
,
$this
->
_result
->
getLists
());
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
_items
),
count
(
$this
->
_result
));
}
public
function
testIterator
()
{
$lists
=
array
();
foreach
(
$this
->
_result
AS
$key
=>
$list
)
{
$lists
[
$key
]
=
$list
;
}
$this
->
assertEquals
(
$this
->
_items
,
$lists
);
}
public
function
testGetStatus
()
{
$this
->
assertEquals
(
1
,
$this
->
_result
->
getStatus
()
);
}
public
function
testGetQueryTime
()
{
$this
->
assertEquals
(
12
,
$this
->
_result
->
getQueryTime
()
);
}
}
class
Solarium_Result_Analysis_FieldDummy
extends
Solarium_Result_Analysis_Field
{
protected
$_parsed
=
true
;
public
function
__construct
(
$status
,
$queryTime
,
$items
)
{
$this
->
_items
=
$items
;
$this
->
_queryTime
=
$queryTime
;
$this
->
_status
=
$status
;
}
}
\ No newline at end of file
tests/Solarium/Result/Analysis/ItemTest.php
0 → 100644
View file @
2915f8cc
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class
Solarium_Result_Analysis_ItemTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Analysis_Item
*/
protected
$_item
;
protected
$_data
;
public
function
setUp
()
{
$this
->
_data
=
array
(
'text'
=>
'dummytest'
,
'start'
=>
10
,
'end'
=>
22
,
'position'
=>
2
,
'positionHistory'
=>
array
(
2
,
1
),
'type'
=>
'<dummytype>'
,
'raw_text'
=>
'dummy raw text'
);
$this
->
_item
=
new
Solarium_Result_Analysis_Item
(
$this
->
_data
);
}
public
function
testGetText
()
{
$this
->
assertEquals
(
$this
->
_data
[
'text'
],
$this
->
_item
->
getText
());
}
public
function
testGetStart
()
{
$this
->
assertEquals
(
$this
->
_data
[
'start'
],
$this
->
_item
->
getStart
());
}
public
function
testGetEnd
()
{
$this
->
assertEquals
(
$this
->
_data
[
'end'
],
$this
->
_item
->
getEnd
());
}
public
function
testGetPosition
()
{
$this
->
assertEquals
(
$this
->
_data
[
'position'
],
$this
->
_item
->
getPosition
());
}
public
function
testGetPositionHistory
()
{
$this
->
assertEquals
(
$this
->
_data
[
'positionHistory'
],
$this
->
_item
->
getPositionHistory
());
}
public
function
testGetRawText
()
{
$this
->
assertEquals
(
$this
->
_data
[
'raw_text'
],
$this
->
_item
->
getRawText
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
$this
->
_data
[
'type'
],
$this
->
_item
->
getType
());
}
public
function
testGetRawTextEmpty
()
{
$data
=
array
(
'text'
=>
'dummytest'
,
'start'
=>
10
,
'end'
=>
22
,
'position'
=>
2
,
'positionHistory'
=>
array
(
2
,
1
),
'type'
=>
'<dummytype>'
,
);
$item
=
new
Solarium_Result_Analysis_Item
(
$data
);
$this
->
assertEquals
(
null
,
$item
->
getRawText
());
}
}
\ No newline at end of file
tests/Solarium/Result/Analysis/ListTest.php
0 → 100644
View file @
2915f8cc
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class
Solarium_Result_Analysis_ListTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Analysis_List
*/
protected
$_result
;
protected
$_items
,
$_name
;
public
function
setUp
()
{
$this
->
_name
=
'testname'
;
$this
->
_items
=
array
(
'key1'
=>
'dummy1'
,
'key2'
=>
'dummy2'
,
'key3'
=>
'dummy3'
);
$this
->
_result
=
new
Solarium_Result_Analysis_List
(
$this
->
_name
,
$this
->
_items
);
}
public
function
testGetItems
()
{
$this
->
assertEquals
(
$this
->
_items
,
$this
->
_result
->
getItems
());
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
_items
),
count
(
$this
->
_result
));
}
public
function
testIterator
()
{
$lists
=
array
();
foreach
(
$this
->
_result
AS
$key
=>
$list
)
{
$lists
[
$key
]
=
$list
;
}
$this
->
assertEquals
(
$this
->
_items
,
$lists
);
}
public
function
testGetName
()
{
$this
->
assertEquals
(
$this
->
_name
,
$this
->
_result
->
getName
()
);
}
}
\ No newline at end of file
tests/Solarium/Result/Analysis/TypesTest.php
0 → 100644
View file @
2915f8cc
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class
Solarium_Result_Analysis_TypesTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Analysis_Types
*/
protected
$_result
;
protected
$_items
,
$_name
;
public
function
setUp
()
{
$this
->
_name
=
'testname'
;
$this
->
_items
=
array
(
'index'
=>
new
testAnalysisTypeIndexDummy
(),
'query'
=>
new
testAnalysisTypeQueryDummy
()
);
$this
->
_result
=
new
Solarium_Result_Analysis_Types
(
$this
->
_name
,
$this
->
_items
);
}
public
function
testGetItems
()
{
$this
->
assertEquals
(
$this
->
_items
,
$this
->
_result
->
getItems
());
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
_items
),
count
(
$this
->
_result
));
}
public
function
testIterator
()
{
$lists
=
array
();
foreach
(
$this
->
_result
AS
$key
=>
$list
)
{
$lists
[
$key
]
=
$list
;
}
$this
->
assertEquals
(
$this
->
_items
,
$lists
);
}
public
function
testGetName
()
{
$this
->
assertEquals
(
$this
->
_name
,
$this
->
_result
->
getName
()
);
}
public
function
testGetIndexAnalysis
()
{
$this
->
assertEquals
(
$this
->
_items
[
'index'
],
$this
->
_result
->
getIndexAnalysis
()
);
}
public
function
testGetIndexAnalysisNoData
()
{
$items
=
array
(
'index'
=>
new
testAnalysisTypeInvalidDummy
(),
'query'
=>
new
testAnalysisTypeQueryDummy
()
);
$result
=
new
Solarium_Result_Analysis_Types
(
$this
->
_name
,
$items
);
$this
->
assertEquals
(
null
,
$result
->
getIndexAnalysis
()
);
}
public
function
testGetQueryAnalysis
()
{
$this
->
assertEquals
(
$this
->
_items
[
'query'
],
$this
->
_result
->
getQueryAnalysis
()
);
}
public
function
testGetQueryAnalysisNoData
()
{
$items
=
array
(
'index'
=>
new
testAnalysisTypeIndexDummy
(),
'query'
=>
new
testAnalysisTypeInvalidDummy
()
);
$result
=
new
Solarium_Result_Analysis_Types
(
$this
->
_name
,
$items
);
$this
->
assertEquals
(
null
,
$result
->
getQueryAnalysis
()
);
}
}
class
testAnalysisTypeIndexDummy
{
public
function
getName
(){
return
'index'
;
}
}
class
testAnalysisTypeQueryDummy
{
public
function
getName
(){
return
'query'
;
}
}
class
testAnalysisTypeInvalidDummy
{
public
function
getName
(){
return
'invalid'
;
}
}
\ 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