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
1e442fc1
Commit
1e442fc1
authored
Dec 22, 2014
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:basdenooijer/solarium into develop
parents
f1ac3c40
7b053fcb
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1176 additions
and
983 deletions
+1176
-983
library/Solarium/Plugin/MinimumScoreFilter/Document.php
library/Solarium/Plugin/MinimumScoreFilter/Document.php
+11
-0
library/Solarium/QueryType/Select/Result/AbstractDocument.php
...ary/Solarium/QueryType/Select/Result/AbstractDocument.php
+14
-0
tests/Solarium/Tests/Plugin/MinimumScoreFilter/DocumentTest.php
...Solarium/Tests/Plugin/MinimumScoreFilter/DocumentTest.php
+2
-2
tests/Solarium/Tests/Plugin/MinimumScoreFilter/QueryTest.php
tests/Solarium/Tests/Plugin/MinimumScoreFilter/QueryTest.php
+2
-3
tests/Solarium/Tests/Plugin/MinimumScoreFilter/ResultTest.php
...s/Solarium/Tests/Plugin/MinimumScoreFilter/ResultTest.php
+2
-2
tests/Solarium/Tests/QueryType/Extract/ResultTest.php
tests/Solarium/Tests/QueryType/Extract/ResultTest.php
+2
-2
tests/Solarium/Tests/QueryType/Select/Query/AbstractQueryTest.php
...larium/Tests/QueryType/Select/Query/AbstractQueryTest.php
+711
-0
tests/Solarium/Tests/QueryType/Select/Query/QueryTest.php
tests/Solarium/Tests/QueryType/Select/Query/QueryTest.php
+1
-675
tests/Solarium/Tests/QueryType/Select/Result/AbstractDocumentTest.php
...um/Tests/QueryType/Select/Result/AbstractDocumentTest.php
+152
-0
tests/Solarium/Tests/QueryType/Select/Result/AbstractResultTest.php
...rium/Tests/QueryType/Select/Result/AbstractResultTest.php
+222
-0
tests/Solarium/Tests/QueryType/Select/Result/DocumentTest.php
...s/Solarium/Tests/QueryType/Select/Result/DocumentTest.php
+1
-93
tests/Solarium/Tests/QueryType/Select/Result/ResultTest.php
tests/Solarium/Tests/QueryType/Select/Result/ResultTest.php
+2
-184
tests/Solarium/Tests/QueryType/Update/AbstractResultTest.php
tests/Solarium/Tests/QueryType/Update/AbstractResultTest.php
+53
-0
tests/Solarium/Tests/QueryType/Update/ResultTest.php
tests/Solarium/Tests/QueryType/Update/ResultTest.php
+1
-22
No files found.
library/Solarium/Plugin/MinimumScoreFilter/Document.php
View file @
1e442fc1
...
@@ -104,6 +104,17 @@ class Document implements \IteratorAggregate, \Countable, \ArrayAccess
...
@@ -104,6 +104,17 @@ class Document implements \IteratorAggregate, \Countable, \ArrayAccess
return
$this
->
document
->
__get
(
$name
);
return
$this
->
document
->
__get
(
$name
);
}
}
/**
* Forward isset call to the original document
*
* @param string $name
* @return boolean
*/
public
function
__isset
(
$name
)
{
return
$this
->
document
->
__isset
(
$name
);
}
/**
/**
* IteratorAggregate implementation
* IteratorAggregate implementation
*
*
...
...
library/Solarium/QueryType/Select/Result/AbstractDocument.php
View file @
1e442fc1
...
@@ -78,6 +78,20 @@ abstract class AbstractDocument implements \IteratorAggregate, \Countable, \Arra
...
@@ -78,6 +78,20 @@ abstract class AbstractDocument implements \IteratorAggregate, \Countable, \Arra
return
$this
->
fields
[
$name
];
return
$this
->
fields
[
$name
];
}
}
/**
* Check if field is set by name
*
* Magic method for checking if fields are set as properties of this document
* object, by field name. Also used by empty().
*
* @param string $name
* @return boolean
*/
public
function
__isset
(
$name
)
{
return
isset
(
$this
->
fields
[
$name
]);
}
/**
/**
* IteratorAggregate implementation
* IteratorAggregate implementation
*
*
...
...
tests/Solarium/Tests/Plugin/MinimumScoreFilter/DocumentTest.php
View file @
1e442fc1
...
@@ -33,9 +33,9 @@ namespace Solarium\Tests\Plugin\MinimumScoreFilter;
...
@@ -33,9 +33,9 @@ namespace Solarium\Tests\Plugin\MinimumScoreFilter;
use
Solarium\QueryType\Select\Result\Document
;
use
Solarium\QueryType\Select\Result\Document
;
use
Solarium\Plugin\MinimumScoreFilter\Document
as
FilterDocument
;
use
Solarium\Plugin\MinimumScoreFilter\Document
as
FilterDocument
;
use
Solarium\Tests\QueryType\Select\Result\
DocumentTest
as
Sele
ctDocumentTest
;
use
Solarium\Tests\QueryType\Select\Result\
Abstra
ctDocumentTest
;
class
DocumentTest
extends
Sele
ctDocumentTest
class
DocumentTest
extends
Abstra
ctDocumentTest
{
{
protected
function
setUp
()
protected
function
setUp
()
{
{
...
...
tests/Solarium/Tests/Plugin/MinimumScoreFilter/QueryTest.php
View file @
1e442fc1
...
@@ -32,11 +32,10 @@
...
@@ -32,11 +32,10 @@
namespace
Solarium\Tests\Plugin\MinimumScoreFilter
;
namespace
Solarium\Tests\Plugin\MinimumScoreFilter
;
use
Solarium\Plugin\MinimumScoreFilter\Query
;
use
Solarium\Plugin\MinimumScoreFilter\Query
;
use
Solarium\Tests\QueryType\Select\Query\
QueryTest
as
Sele
ctQueryTest
;
use
Solarium\Tests\QueryType\Select\Query\
Abstra
ctQueryTest
;
class
QueryTest
extends
Sele
ctQueryTest
class
QueryTest
extends
Abstra
ctQueryTest
{
{
public
function
setUp
()
public
function
setUp
()
{
{
$this
->
query
=
new
Query
;
$this
->
query
=
new
Query
;
...
...
tests/Solarium/Tests/Plugin/MinimumScoreFilter/ResultTest.php
View file @
1e442fc1
...
@@ -34,9 +34,9 @@ namespace Solarium\Tests\Plugin\MinimumScoreFilter;
...
@@ -34,9 +34,9 @@ namespace Solarium\Tests\Plugin\MinimumScoreFilter;
use
Solarium\Plugin\MinimumScoreFilter\Query
;
use
Solarium\Plugin\MinimumScoreFilter\Query
;
use
Solarium\Plugin\MinimumScoreFilter\Result
;
use
Solarium\Plugin\MinimumScoreFilter\Result
;
use
Solarium\QueryType\Select\Result\Document
;
use
Solarium\QueryType\Select\Result\Document
;
use
Solarium\Tests\QueryType\Select\Result\
ResultTest
as
Sele
ctResultTest
;
use
Solarium\Tests\QueryType\Select\Result\
Abstra
ctResultTest
;
class
ResultTest
extends
Sele
ctResultTest
class
ResultTest
extends
Abstra
ctResultTest
{
{
public
function
setUp
()
public
function
setUp
()
{
{
...
...
tests/Solarium/Tests/QueryType/Extract/ResultTest.php
View file @
1e442fc1
...
@@ -31,10 +31,10 @@
...
@@ -31,10 +31,10 @@
namespace
Solarium\Tests\QueryType\Extract
;
namespace
Solarium\Tests\QueryType\Extract
;
use
Solarium\Tests\QueryType\Update\ResultTest
as
UpdateResultTest
;
use
Solarium\QueryType\Extract\Result
as
ExtractResult
;
use
Solarium\QueryType\Extract\Result
as
ExtractResult
;
use
Solarium\Tests\QueryType\Update\AbstractResultTest
;
class
ResultTest
extends
Update
ResultTest
class
ResultTest
extends
Abstract
ResultTest
{
{
public
function
setUp
()
public
function
setUp
()
{
{
...
...
tests/Solarium/Tests/QueryType/Select/Query/AbstractQueryTest.php
0 → 100644
View file @
1e442fc1
This diff is collapsed.
Click to expand it.
tests/Solarium/Tests/QueryType/Select/Query/QueryTest.php
View file @
1e442fc1
This diff is collapsed.
Click to expand it.
tests/Solarium/Tests/QueryType/Select/Result/AbstractDocumentTest.php
0 → 100644
View file @
1e442fc1
<?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.
*/
namespace
Solarium\Tests\QueryType\Select\Result
;
abstract
class
AbstractDocumentTest
extends
\PHPUnit_Framework_TestCase
{
protected
$doc
;
protected
$fields
=
array
(
'id'
=>
123
,
'name'
=>
'Test document'
,
'categories'
=>
array
(
1
,
2
,
3
),
'empty_field'
=>
''
,
);
public
function
testGetFields
()
{
$this
->
assertEquals
(
$this
->
fields
,
$this
->
doc
->
getFields
());
}
public
function
testGetFieldAsProperty
()
{
$this
->
assertEquals
(
$this
->
fields
[
'categories'
],
$this
->
doc
->
categories
);
$this
->
assertEquals
(
null
,
$this
->
doc
->
invalidfieldname
);
}
public
function
testPropertyIsset
()
{
$this
->
assertTrue
(
isset
(
$this
->
doc
->
categories
)
);
$this
->
assertFalse
(
isset
(
$this
->
doc
->
invalidfieldname
)
);
}
public
function
testPropertyEmpty
()
{
$this
->
assertTrue
(
empty
(
$this
->
doc
->
empty_field
)
);
$this
->
assertFalse
(
empty
(
$this
->
doc
->
categories
)
);
}
public
function
testSetField
()
{
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
$this
->
doc
->
newField
=
'new value'
;
}
public
function
testIterator
()
{
$fields
=
array
();
foreach
(
$this
->
doc
as
$key
=>
$field
)
{
$fields
[
$key
]
=
$field
;
}
$this
->
assertEquals
(
$this
->
fields
,
$fields
);
}
public
function
testArrayGet
()
{
$this
->
assertEquals
(
$this
->
fields
[
'categories'
],
$this
->
doc
[
'categories'
]
);
$this
->
assertEquals
(
null
,
$this
->
doc
[
'invalidfieldname'
]
);
}
public
function
testArrayIsset
()
{
$this
->
assertTrue
(
isset
(
$this
->
doc
[
'categories'
])
);
$this
->
assertFalse
(
isset
(
$this
->
doc
[
'invalidfieldname'
])
);
}
public
function
testArrayEmpty
()
{
$this
->
assertTrue
(
empty
(
$this
->
doc
[
'empty_field'
])
);
$this
->
assertFalse
(
empty
(
$this
->
doc
[
'categories'
])
);
}
public
function
testArraySet
()
{
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
$this
->
doc
[
'newField'
]
=
'new value'
;
}
public
function
testArrayUnset
()
{
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
unset
(
$this
->
doc
[
'newField'
]);
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
fields
),
count
(
$this
->
doc
));
}
}
tests/Solarium/Tests/QueryType/Select/Result/AbstractResultTest.php
0 → 100644
View file @
1e442fc1
<?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.
*/
namespace
Solarium\Tests\QueryType\Select\Result
;
use
Solarium\QueryType\Select\Result\Document
;
use
Solarium\QueryType\Select\Query\Query
;
use
Solarium\QueryType\Select\Result\Result
;
abstract
class
AbstractResultTest
extends
\PHPUnit_Framework_TestCase
{
/**
* @var SelectDummy
*/
protected
$result
;
protected
$numFound
;
protected
$maxScore
;
protected
$docs
;
protected
$components
;
protected
$facetSet
;
protected
$moreLikeThis
;
protected
$highlighting
;
protected
$grouping
;
protected
$stats
;
protected
$debug
;
protected
$spellcheck
;
public
function
setUp
()
{
$this
->
numFound
=
11
;
$this
->
maxScore
=
0.91
;
$this
->
docs
=
array
(
new
Document
(
array
(
'id'
=>
1
,
'title'
=>
'doc1'
)),
new
Document
(
array
(
'id'
=>
1
,
'title'
=>
'doc1'
)),
);
$this
->
facetSet
=
'dummy-facetset-value'
;
$this
->
moreLikeThis
=
'dummy-facetset-value'
;
$this
->
highlighting
=
'dummy-highlighting-value'
;
$this
->
grouping
=
'dummy-grouping-value'
;
$this
->
spellcheck
=
'dummy-grouping-value'
;
$this
->
stats
=
'dummy-stats-value'
;
$this
->
debug
=
'dummy-debug-value'
;
$this
->
components
=
array
(
Query
::
COMPONENT_FACETSET
=>
$this
->
facetSet
,
Query
::
COMPONENT_MORELIKETHIS
=>
$this
->
moreLikeThis
,
Query
::
COMPONENT_HIGHLIGHTING
=>
$this
->
highlighting
,
Query
::
COMPONENT_GROUPING
=>
$this
->
grouping
,
Query
::
COMPONENT_SPELLCHECK
=>
$this
->
spellcheck
,
Query
::
COMPONENT_STATS
=>
$this
->
stats
,
Query
::
COMPONENT_DEBUG
=>
$this
->
debug
,
);
$this
->
result
=
new
SelectDummy
(
1
,
12
,
$this
->
numFound
,
$this
->
maxScore
,
$this
->
docs
,
$this
->
components
);
}
public
function
testGetNumFound
()
{
$this
->
assertEquals
(
$this
->
numFound
,
$this
->
result
->
getNumFound
());
}
public
function
testGetMaxScore
()
{
$this
->
assertEquals
(
$this
->
maxScore
,
$this
->
result
->
getMaxScore
());
}
public
function
testGetDocuments
()
{
$this
->
assertEquals
(
$this
->
docs
,
$this
->
result
->
getDocuments
());
}
public
function
testGetFacetSet
()
{
$this
->
assertEquals
(
$this
->
facetSet
,
$this
->
result
->
getFacetSet
());
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
docs
),
count
(
$this
->
result
));
}
public
function
testGetComponents
()
{
$this
->
assertEquals
(
$this
->
components
,
$this
->
result
->
getComponents
());
}
public
function
testGetComponent
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_MORELIKETHIS
],
$this
->
result
->
getComponent
(
Query
::
COMPONENT_MORELIKETHIS
)
);
}
public
function
testGetInvalidComponent
()
{
$this
->
assertEquals
(
null
,
$this
->
result
->
getComponent
(
'invalid'
)
);
}
public
function
testGetMoreLikeThis
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_MORELIKETHIS
],
$this
->
result
->
getMoreLikeThis
()
);
}
public
function
testGetHighlighting
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_HIGHLIGHTING
],
$this
->
result
->
getHighlighting
()
);
}
public
function
testGetGrouping
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_GROUPING
],
$this
->
result
->
getGrouping
()
);
}
public
function
testGetSpellcheck
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_SPELLCHECK
],
$this
->
result
->
getSpellcheck
()
);
}
public
function
testGetStats
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_STATS
],
$this
->
result
->
getStats
()
);
}
public
function
testGetDebug
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_DEBUG
],
$this
->
result
->
getDebug
()
);
}
public
function
testIterator
()
{
$docs
=
array
();
foreach
(
$this
->
result
as
$key
=>
$doc
)
{
$docs
[
$key
]
=
$doc
;
}
$this
->
assertEquals
(
$this
->
docs
,
$docs
);
}
public
function
testGetStatus
()
{
$this
->
assertEquals
(
1
,
$this
->
result
->
getStatus
()
);
}
public
function
testGetQueryTime
()
{
$this
->
assertEquals
(
12
,
$this
->
result
->
getQueryTime
()
);
}
}
class
SelectDummy
extends
Result
{
protected
$parsed
=
true
;
public
function
__construct
(
$status
,
$queryTime
,
$numfound
,
$maxscore
,
$docs
,
$components
)
{
$this
->
numfound
=
$numfound
;
$this
->
maxscore
=
$maxscore
;
$this
->
documents
=
$docs
;
$this
->
components
=
$components
;
$this
->
queryTime
=
$queryTime
;
$this
->
status
=
$status
;
}
}
tests/Solarium/Tests/QueryType/Select/Result/DocumentTest.php
View file @
1e442fc1
...
@@ -33,102 +33,10 @@ namespace Solarium\Tests\QueryType\Select\Result;
...
@@ -33,102 +33,10 @@ namespace Solarium\Tests\QueryType\Select\Result;
use
Solarium\QueryType\Select\Result\Document
;
use
Solarium\QueryType\Select\Result\Document
;
class
DocumentTest
extends
\PHPUnit_Framework_TestCase
class
DocumentTest
extends
AbstractDocumentTest
{
{
protected
$doc
;
protected
$fields
=
array
(
'id'
=>
123
,
'name'
=>
'Test document'
,
'categories'
=>
array
(
1
,
2
,
3
)
);
protected
function
setUp
()
protected
function
setUp
()
{
{
$this
->
doc
=
new
Document
(
$this
->
fields
);
$this
->
doc
=
new
Document
(
$this
->
fields
);
}
}
public
function
testGetFields
()
{
$this
->
assertEquals
(
$this
->
fields
,
$this
->
doc
->
getFields
());
}
public
function
testGetFieldAsProperty
()
{
$this
->
assertEquals
(
$this
->
fields
[
'categories'
],
$this
->
doc
->
categories
);
}
public
function
testGetInvalidFieldAsProperty
()
{
$this
->
assertEquals
(
null
,
$this
->
doc
->
invalidfieldname
);
}
public
function
testSetField
()
{
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
$this
->
doc
->
newField
=
'new value'
;
}
public
function
testIterator
()
{
$fields
=
array
();
foreach
(
$this
->
doc
as
$key
=>
$field
)
{
$fields
[
$key
]
=
$field
;
}
$this
->
assertEquals
(
$this
->
fields
,
$fields
);
}
public
function
testArrayGet
()
{
$this
->
assertEquals
(
$this
->
fields
[
'categories'
],
$this
->
doc
[
'categories'
]
);
}
public
function
testArrayGetInvalidField
()
{
$this
->
assertEquals
(
null
,
$this
->
doc
[
'invalidfield'
]
);
}
public
function
testArrayIsset
()
{
$this
->
assertTrue
(
isset
(
$this
->
doc
[
'categories'
])
);
}
public
function
testArrayIssetInvalidField
()
{
$this
->
assertFalse
(
isset
(
$this
->
doc
[
'invalidfield'
])
);
}
public
function
testArraySet
()
{
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
$this
->
doc
[
'newField'
]
=
'new value'
;
}
public
function
testArrayUnset
()
{
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
unset
(
$this
->
doc
[
'newField'
]);
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
fields
),
count
(
$this
->
doc
));
}
}
}
tests/Solarium/Tests/QueryType/Select/Result/ResultTest.php
View file @
1e442fc1
...
@@ -31,192 +31,10 @@
...
@@ -31,192 +31,10 @@
namespace
Solarium\Tests\QueryType\Select\Result
;
namespace
Solarium\Tests\QueryType\Select\Result
;
use
Solarium\QueryType\Select\Result\Document
;
class
ResultTest
extends
AbstractResultTest
use
Solarium\QueryType\Select\Query\Query
;
use
Solarium\QueryType\Select\Result\Result
;
class
ResultTest
extends
\PHPUnit_Framework_TestCase
{
{
/**
* @var SelectDummy
*/
protected
$result
;
protected
$numFound
;
protected
$maxScore
;
protected
$docs
;
protected
$components
;
protected
$facetSet
;
protected
$moreLikeThis
;
protected
$highlighting
;
protected
$grouping
;
protected
$stats
;
protected
$debug
;
protected
$spellcheck
;
public
function
setUp
()
public
function
setUp
()
{
{
$this
->
numFound
=
11
;
parent
::
setUp
();
$this
->
maxScore
=
0.91
;
$this
->
docs
=
array
(
new
Document
(
array
(
'id'
=>
1
,
'title'
=>
'doc1'
)),
new
Document
(
array
(
'id'
=>
1
,
'title'
=>
'doc1'
)),
);
$this
->
facetSet
=
'dummy-facetset-value'
;
$this
->
moreLikeThis
=
'dummy-facetset-value'
;
$this
->
highlighting
=
'dummy-highlighting-value'
;
$this
->
grouping
=
'dummy-grouping-value'
;
$this
->
spellcheck
=
'dummy-grouping-value'
;
$this
->
stats
=
'dummy-stats-value'
;
$this
->
debug
=
'dummy-debug-value'
;
$this
->
components
=
array
(
Query
::
COMPONENT_FACETSET
=>
$this
->
facetSet
,
Query
::
COMPONENT_MORELIKETHIS
=>
$this
->
moreLikeThis
,
Query
::
COMPONENT_HIGHLIGHTING
=>
$this
->
highlighting
,
Query
::
COMPONENT_GROUPING
=>
$this
->
grouping
,
Query
::
COMPONENT_SPELLCHECK
=>
$this
->
spellcheck
,
Query
::
COMPONENT_STATS
=>
$this
->
stats
,
Query
::
COMPONENT_DEBUG
=>
$this
->
debug
,
);
$this
->
result
=
new
SelectDummy
(
1
,
12
,
$this
->
numFound
,
$this
->
maxScore
,
$this
->
docs
,
$this
->
components
);
}
public
function
testGetNumFound
()
{
$this
->
assertEquals
(
$this
->
numFound
,
$this
->
result
->
getNumFound
());
}
public
function
testGetMaxScore
()
{
$this
->
assertEquals
(
$this
->
maxScore
,
$this
->
result
->
getMaxScore
());
}
public
function
testGetDocuments
()
{
$this
->
assertEquals
(
$this
->
docs
,
$this
->
result
->
getDocuments
());
}
public
function
testGetFacetSet
()
{
$this
->
assertEquals
(
$this
->
facetSet
,
$this
->
result
->
getFacetSet
());
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
docs
),
count
(
$this
->
result
));
}
public
function
testGetComponents
()
{
$this
->
assertEquals
(
$this
->
components
,
$this
->
result
->
getComponents
());
}
public
function
testGetComponent
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_MORELIKETHIS
],
$this
->
result
->
getComponent
(
Query
::
COMPONENT_MORELIKETHIS
)
);
}
public
function
testGetInvalidComponent
()
{
$this
->
assertEquals
(
null
,
$this
->
result
->
getComponent
(
'invalid'
)
);
}
public
function
testGetMoreLikeThis
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_MORELIKETHIS
],
$this
->
result
->
getMoreLikeThis
()
);
}
public
function
testGetHighlighting
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_HIGHLIGHTING
],
$this
->
result
->
getHighlighting
()
);
}
public
function
testGetGrouping
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_GROUPING
],
$this
->
result
->
getGrouping
()
);
}
public
function
testGetSpellcheck
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_SPELLCHECK
],
$this
->
result
->
getSpellcheck
()
);
}
public
function
testGetStats
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_STATS
],
$this
->
result
->
getStats
()
);
}
public
function
testGetDebug
()
{
$this
->
assertEquals
(
$this
->
components
[
Query
::
COMPONENT_DEBUG
],
$this
->
result
->
getDebug
()
);
}
public
function
testIterator
()
{
$docs
=
array
();
foreach
(
$this
->
result
as
$key
=>
$doc
)
{
$docs
[
$key
]
=
$doc
;
}
$this
->
assertEquals
(
$this
->
docs
,
$docs
);
}
public
function
testGetStatus
()
{
$this
->
assertEquals
(
1
,
$this
->
result
->
getStatus
()
);
}
public
function
testGetQueryTime
()
{
$this
->
assertEquals
(
12
,
$this
->
result
->
getQueryTime
()
);
}
}
class
SelectDummy
extends
Result
{
protected
$parsed
=
true
;
public
function
__construct
(
$status
,
$queryTime
,
$numfound
,
$maxscore
,
$docs
,
$components
)
{
$this
->
numfound
=
$numfound
;
$this
->
maxscore
=
$maxscore
;
$this
->
documents
=
$docs
;
$this
->
components
=
$components
;
$this
->
queryTime
=
$queryTime
;
$this
->
status
=
$status
;
}
}
}
}
tests/Solarium/Tests/QueryType/Update/AbstractResultTest.php
0 → 100644
View file @
1e442fc1
<?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.
*/
namespace
Solarium\Tests\QueryType\Update
;
abstract
class
AbstractResultTest
extends
\PHPUnit_Framework_TestCase
{
protected
$result
;
public
function
testGetStatus
()
{
$this
->
assertEquals
(
1
,
$this
->
result
->
getStatus
()
);
}
public
function
testGetQueryTime
()
{
$this
->
assertEquals
(
12
,
$this
->
result
->
getQueryTime
()
);
}
}
tests/Solarium/Tests/QueryType/Update/ResultTest.php
View file @
1e442fc1
...
@@ -33,33 +33,12 @@ namespace Solarium\Tests\QueryType\Update;
...
@@ -33,33 +33,12 @@ namespace Solarium\Tests\QueryType\Update;
use
Solarium\QueryType\Update\Result
as
UpdateResult
;
use
Solarium\QueryType\Update\Result
as
UpdateResult
;
class
ResultTest
extends
\PHPUnit_Framework_TestCase
class
ResultTest
extends
AbstractResultTest
{
{
/**
* @var UpdateDummy
*/
protected
$result
;
public
function
setUp
()
public
function
setUp
()
{
{
$this
->
result
=
new
UpdateDummy
();
$this
->
result
=
new
UpdateDummy
();
}
}
public
function
testGetStatus
()
{
$this
->
assertEquals
(
1
,
$this
->
result
->
getStatus
()
);
}
public
function
testGetQueryTime
()
{
$this
->
assertEquals
(
12
,
$this
->
result
->
getQueryTime
()
);
}
}
}
class
UpdateDummy
extends
UpdateResult
class
UpdateDummy
extends
UpdateResult
...
...
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