[7576] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * Copyright 2011 Bas de Nooijer. All rights reserved. |
---|
| 4 | * |
---|
| 5 | * Redistribution and use in source and binary forms, with or without |
---|
| 6 | * modification, are permitted provided that the following conditions are met: |
---|
| 7 | * |
---|
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
| 9 | * this list of conditions and the following disclaimer. |
---|
| 10 | * |
---|
| 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
| 12 | * this listof conditions and the following disclaimer in the documentation |
---|
| 13 | * and/or other materials provided with the distribution. |
---|
| 14 | * |
---|
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" |
---|
| 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
---|
| 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
| 25 | * POSSIBILITY OF SUCH DAMAGE. |
---|
| 26 | * |
---|
| 27 | * The views and conclusions contained in the software and documentation are |
---|
| 28 | * those of the authors and should not be interpreted as representing official |
---|
| 29 | * policies, either expressed or implied, of the copyright holder. |
---|
| 30 | */ |
---|
| 31 | |
---|
| 32 | class Solarium_Query_Select_Component_Facet_FieldTest extends PHPUnit_Framework_TestCase |
---|
| 33 | { |
---|
| 34 | |
---|
| 35 | /** |
---|
| 36 | * @var Solarium_Query_Select_Component_Facet_Field |
---|
| 37 | */ |
---|
| 38 | protected $_facet; |
---|
| 39 | |
---|
| 40 | public function setUp() |
---|
| 41 | { |
---|
| 42 | $this->_facet = new Solarium_Query_Select_Component_Facet_Field; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | public function testConfigMode() |
---|
| 46 | { |
---|
| 47 | $options = array( |
---|
| 48 | 'key' => 'myKey', |
---|
| 49 | 'exclude' => array('e1','e2'), |
---|
| 50 | 'field' => 'text', |
---|
| 51 | 'sort' => 'index', |
---|
| 52 | 'limit' => 10, |
---|
| 53 | 'offset' => 20, |
---|
| 54 | 'mincount' => 5, |
---|
| 55 | 'missing' => true, |
---|
| 56 | 'method' => 'enum', |
---|
| 57 | ); |
---|
| 58 | |
---|
| 59 | $this->_facet->setOptions($options); |
---|
| 60 | |
---|
| 61 | $this->assertEquals($options['key'], $this->_facet->getKey()); |
---|
| 62 | $this->assertEquals($options['exclude'], $this->_facet->getExcludes()); |
---|
| 63 | $this->assertEquals($options['field'], $this->_facet->getField()); |
---|
| 64 | $this->assertEquals($options['sort'], $this->_facet->getSort()); |
---|
| 65 | $this->assertEquals($options['limit'], $this->_facet->getLimit()); |
---|
| 66 | $this->assertEquals($options['offset'], $this->_facet->getOffset()); |
---|
| 67 | $this->assertEquals($options['mincount'], $this->_facet->getMinCount()); |
---|
| 68 | $this->assertEquals($options['missing'], $this->_facet->getMissing()); |
---|
| 69 | $this->assertEquals($options['method'], $this->_facet->getMethod()); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | public function testGetType() |
---|
| 73 | { |
---|
| 74 | $this->assertEquals( |
---|
| 75 | Solarium_Query_Select_Component_FacetSet::FACET_FIELD, |
---|
| 76 | $this->_facet->getType() |
---|
| 77 | ); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | public function testSetAndGetField() |
---|
| 81 | { |
---|
| 82 | $this->_facet->setField('category'); |
---|
| 83 | $this->assertEquals('category', $this->_facet->getField()); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | public function testSetAndGetSort() |
---|
| 87 | { |
---|
| 88 | $this->_facet->setSort('index'); |
---|
| 89 | $this->assertEquals('index', $this->_facet->getSort()); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | public function testSetAndGetPrefix() |
---|
| 93 | { |
---|
| 94 | $this->_facet->setPrefix('xyz'); |
---|
| 95 | $this->assertEquals('xyz', $this->_facet->getPrefix()); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | public function testSetAndGetLimit() |
---|
| 99 | { |
---|
| 100 | $this->_facet->setLimit(12); |
---|
| 101 | $this->assertEquals(12, $this->_facet->getLimit()); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | public function testSetAndGetOffset() |
---|
| 105 | { |
---|
| 106 | $this->_facet->setOffset(40); |
---|
| 107 | $this->assertEquals(40, $this->_facet->getOffset()); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | public function testSetAndGetMinCount() |
---|
| 111 | { |
---|
| 112 | $this->_facet->setMincount(100); |
---|
| 113 | $this->assertEquals(100, $this->_facet->getMincount()); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | public function testSetAndGetMissing() |
---|
| 117 | { |
---|
| 118 | $this->_facet->setMissing(true); |
---|
| 119 | $this->assertEquals(true, $this->_facet->getMissing()); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | public function testSetAndGetMethod() |
---|
| 123 | { |
---|
| 124 | $this->_facet->setMethod('enum'); |
---|
| 125 | $this->assertEquals('enum', $this->_facet->getMethod()); |
---|
| 126 | } |
---|
| 127 | } |
---|