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
d9182d68
Commit
d9182d68
authored
Sep 28, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved test coverage
parent
08d86ca8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
417 additions
and
0 deletions
+417
-0
tests/Solarium/Client/ResponseParser/Select/Component/SpellcheckTest.php
...Client/ResponseParser/Select/Component/SpellcheckTest.php
+151
-0
tests/Solarium/Result/Select/Spellcheck/CollationTest.php
tests/Solarium/Result/Select/Spellcheck/CollationTest.php
+85
-0
tests/Solarium/Result/Select/Spellcheck/SuggestionTest.php
tests/Solarium/Result/Select/Spellcheck/SuggestionTest.php
+86
-0
tests/Solarium/Result/Select/SpellcheckTest.php
tests/Solarium/Result/Select/SpellcheckTest.php
+95
-0
No files found.
tests/Solarium/Client/ResponseParser/Select/Component/SpellcheckTest.php
0 → 100644
View file @
d9182d68
<?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_Client_ResponseParser_Select_Component_SpellcheckTest
extends
PHPUnit_Framework_TestCase
{
protected
$_parser
;
public
function
setUp
()
{
$this
->
_parser
=
new
Solarium_Client_ResponseParser_Select_Component_Spellcheck
();
}
public
function
testParseExtended
()
{
$data
=
array
(
'spellcheck'
=>
array
(
'suggestions'
=>
array
(
0
=>
'delll'
,
1
=>
array
(
'numFound'
=>
1
,
'startOffset'
=>
0
,
'endOffset'
=>
5
,
'origFreq'
=>
0
,
'suggestion'
=>
array
(
0
=>
array
(
'word'
=>
'dell'
,
'freq'
=>
1
),
),
),
2
=>
'ultrashar'
,
3
=>
array
(
'numFound'
=>
1
,
'startOffset'
=>
6
,
'endOffset'
=>
15
,
'origFreq'
=>
0
,
'suggestion'
=>
array
(
0
=>
array
(
'word'
=>
'ultrasharp'
,
'freq'
=>
1
),
),
),
4
=>
'correctlySpelled'
,
5
=>
false
,
6
=>
'collation'
,
7
=>
array
(
0
=>
'collationQuery'
,
1
=>
'dell ultrasharp'
,
2
=>
'hits'
,
3
=>
0
,
4
=>
'misspellingsAndCorrections'
,
5
=>
array
(
0
=>
'delll'
,
1
=>
'dell'
,
2
=>
'ultrashar'
,
3
=>
'ultrasharp'
),
),
)
)
);
$result
=
$this
->
_parser
->
parse
(
null
,
null
,
$data
);
$suggestions
=
$result
->
getSuggestions
();
$this
->
assertEquals
(
false
,
$result
->
getCorrectlySpelled
());
$this
->
assertEquals
(
'dell'
,
$suggestions
[
0
]
->
getWord
());
$this
->
assertEquals
(
'dell ultrasharp'
,
$result
->
getCollation
()
->
getQuery
());
}
public
function
testParse
()
{
$data
=
array
(
'spellcheck'
=>
array
(
'suggestions'
=>
array
(
0
=>
'delll'
,
1
=>
array
(
'numFound'
=>
1
,
'startOffset'
=>
0
,
'endOffset'
=>
5
,
'origFreq'
=>
0
,
'suggestion'
=>
array
(
0
=>
'dell'
,
),
),
2
=>
'ultrashar'
,
3
=>
array
(
'numFound'
=>
1
,
'startOffset'
=>
6
,
'endOffset'
=>
15
,
'origFreq'
=>
0
,
'suggestion'
=>
array
(
0
=>
array
(
'word'
=>
'ultrasharp'
,
'freq'
=>
1
),
),
),
4
=>
'correctlySpelled'
,
5
=>
false
,
6
=>
'collation'
,
7
=>
'dell ultrasharp'
,
)
)
);
$result
=
$this
->
_parser
->
parse
(
null
,
null
,
$data
);
$suggestions
=
$result
->
getSuggestions
();
$this
->
assertEquals
(
false
,
$result
->
getCorrectlySpelled
());
$this
->
assertEquals
(
'dell'
,
$suggestions
[
0
]
->
getWord
());
$this
->
assertEquals
(
'dell ultrasharp'
,
$result
->
getCollation
()
->
getQuery
());
}
public
function
testParseNoData
()
{
$result
=
$this
->
_parser
->
parse
(
null
,
null
,
array
());
$this
->
assertEquals
(
null
,
$result
);
}
}
tests/Solarium/Result/Select/Spellcheck/CollationTest.php
0 → 100644
View file @
d9182d68
<?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_Select_Spellcheck_CollationTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Select_Spellcheck_Collation
*/
protected
$_result
;
protected
$_corrections
,
$_hits
,
$_query
;
public
function
setUp
()
{
$this
->
_corrections
=
array
(
'key1'
=>
'content1'
,
'key2'
=>
'content2'
,
);
$this
->
_hits
=
1
;
$this
->
_query
=
'dummy query'
;
$this
->
_result
=
new
Solarium_Result_Select_Spellcheck_Collation
(
$this
->
_query
,
$this
->
_hits
,
$this
->
_corrections
);
}
public
function
testGetQuery
()
{
$this
->
assertEquals
(
$this
->
_query
,
$this
->
_result
->
getQuery
());
}
public
function
testGetHits
()
{
$this
->
assertEquals
(
$this
->
_hits
,
$this
->
_result
->
getHits
());
}
public
function
testGetCorrections
()
{
$this
->
assertEquals
(
$this
->
_corrections
,
$this
->
_result
->
getCorrections
());
}
public
function
testIterator
()
{
$items
=
array
();
foreach
(
$this
->
_result
AS
$key
=>
$item
)
{
$items
[
$key
]
=
$item
;
}
$this
->
assertEquals
(
$this
->
_corrections
,
$items
);
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
_corrections
),
count
(
$this
->
_result
));
}
}
tests/Solarium/Result/Select/Spellcheck/SuggestionTest.php
0 → 100644
View file @
d9182d68
<?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_Select_Spellcheck_SuggestionTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Select_Spellcheck_Suggestion
*/
protected
$_result
;
protected
$_numFound
,
$_startOffset
,
$_endOffset
,
$_originalFrequency
,
$_word
,
$_frequency
;
public
function
setUp
()
{
$this
->
_numFound
=
1
;
$this
->
_startOffset
=
2
;
$this
->
_endOffset
=
3
;
$this
->
_originalFrequency
=
4
;
$this
->
_word
=
'dummyword'
;
$this
->
_frequency
=
5
;
$this
->
_result
=
new
Solarium_Result_Select_Spellcheck_Suggestion
(
$this
->
_numFound
,
$this
->
_startOffset
,
$this
->
_endOffset
,
$this
->
_originalFrequency
,
$this
->
_word
,
$this
->
_frequency
);
}
public
function
testGetNumFound
()
{
$this
->
assertEquals
(
$this
->
_numFound
,
$this
->
_result
->
getNumFound
());
}
public
function
testGetStartOffset
()
{
$this
->
assertEquals
(
$this
->
_startOffset
,
$this
->
_result
->
getStartOffset
());
}
public
function
testGetEndOffset
()
{
$this
->
assertEquals
(
$this
->
_endOffset
,
$this
->
_result
->
getEndOffset
());
}
public
function
testGetOriginalFrequency
()
{
$this
->
assertEquals
(
$this
->
_originalFrequency
,
$this
->
_result
->
getOriginalFrequency
());
}
public
function
testGetWord
()
{
$this
->
assertEquals
(
$this
->
_word
,
$this
->
_result
->
getWord
());
}
public
function
testGetFrequency
()
{
$this
->
assertEquals
(
$this
->
_frequency
,
$this
->
_result
->
getFrequency
());
}
}
tests/Solarium/Result/Select/SpellcheckTest.php
0 → 100644
View file @
d9182d68
<?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_Select_SpellcheckTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Result_Select_Spellcheck
*/
protected
$_result
;
protected
$_suggestions
,
$_collation
,
$_correctlySpelled
;
public
function
setUp
()
{
$this
->
_suggestions
=
array
(
'key1'
=>
'content1'
,
'key2'
=>
'content2'
,
);
$this
->
_collation
=
'dummy1'
;
$this
->
_correctlySpelled
=
false
;
$this
->
_result
=
new
Solarium_Result_Select_Spellcheck
(
$this
->
_suggestions
,
$this
->
_collation
,
$this
->
_correctlySpelled
);
}
public
function
testGetCollation
()
{
$this
->
assertEquals
(
$this
->
_collation
,
$this
->
_result
->
getCollation
());
}
public
function
testGetCorrectlySpelled
()
{
$this
->
assertEquals
(
$this
->
_correctlySpelled
,
$this
->
_result
->
getCorrectlySpelled
());
}
public
function
testGetSuggestion
()
{
$this
->
assertEquals
(
$this
->
_suggestions
[
'key1'
],
$this
->
_result
->
getSuggestion
(
'key1'
));
}
public
function
testGetInvalidSuggestion
()
{
$this
->
assertEquals
(
null
,
$this
->
_result
->
getSuggestion
(
'key3'
));
}
public
function
testGetSuggestions
()
{
$this
->
assertEquals
(
$this
->
_suggestions
,
$this
->
_result
->
getSuggestions
());
}
public
function
testIterator
()
{
$items
=
array
();
foreach
(
$this
->
_result
AS
$key
=>
$item
)
{
$items
[
$key
]
=
$item
;
}
$this
->
assertEquals
(
$this
->
_suggestions
,
$items
);
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
_suggestions
),
count
(
$this
->
_result
));
}
}
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