23 |
24 |
25 | IW-02
26 | 1
27 | New Atomic Update Feature
28 | true
29 |
30 |
31 | REQ;
32 |
33 | $response = $client->request($rawAtomicUpdateRequest)->getResponse();
34 | $client->commit();
35 |
36 | print_r($response);
37 | ?>
38 | --EXPECTF--
39 |
40 | SolrObject Object
41 | (
42 | [responseHeader] => SolrObject Object
43 | (
44 | [status] => %d
45 | [QTime] => %d
46 | )
47 |
48 | )
--------------------------------------------------------------------------------
/tests/016.solrclient_sendUpdateStream_bin.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::sendUpdateStream - send SolrExtractRequest (bin)
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
12 | 'login' => SOLR_SERVER_USERNAME,
13 | 'password' => SOLR_SERVER_PASSWORD,
14 | 'port' => SOLR_SERVER_PORT,
15 | 'path' => SOLR_SERVER_FILES_PATH,
16 | );
17 |
18 | $client = new SolrClient($options);
19 |
20 | $extractParams = new SolrModifiableParams();
21 |
22 | $extractParams
23 | ->set(SolrExtractRequest::LITERALS_PREFIX . 'id', 'doc1')
24 | ->set(SolrExtractRequest::CAPTURE_ELEMENTS, 'p')
25 | ->set(SolrExtractRequest::FIELD_MAPPING_PREFIX . 'p', 'text')
26 | ;
27 |
28 | $binContent = file_get_contents(EXTRACT_FILE_1);
29 |
30 | $extractRequest = SolrExtractRequest::createFromStream($binContent, 'application/pdf', $extractParams);
31 |
32 | $response = $client->sendUpdateStream($extractRequest);
33 |
34 | $client->rollback();
35 |
36 | echo $response->getHttpStatus() . PHP_EOL;
37 | echo $response->getRequestUrl() . PHP_EOL;
38 | ?>
39 | --EXPECTF--
40 | 200
41 | http://%s/update/extract/?version=2.2&indent=on&wt=xml&literal.id=doc1&capture=p&fmap.p=text
42 |
--------------------------------------------------------------------------------
/tests/016.solrclient_sendUpdateStream_file.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::sendUpdateStream - send SolrExtractRequest (file)
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
12 | 'login' => SOLR_SERVER_USERNAME,
13 | 'password' => SOLR_SERVER_PASSWORD,
14 | 'port' => SOLR_SERVER_PORT,
15 | 'path' => SOLR_SERVER_FILES_PATH,
16 | );
17 |
18 | $client = new SolrClient($options);
19 |
20 | $extractParams = new SolrModifiableParams();
21 |
22 | $extractParams
23 | ->set(SolrExtractRequest::LITERALS_PREFIX . 'id', 'doc1')
24 | ->set(SolrExtractRequest::CAPTURE_ELEMENTS, 'p')
25 | ->set(SolrExtractRequest::FIELD_MAPPING_PREFIX . 'p', 'text')
26 | ;
27 |
28 | $extractRequest = SolrExtractRequest::createFromFile(EXTRACT_FILE_1, $extractParams);
29 |
30 | $response = $client->sendUpdateStream($extractRequest);
31 |
32 | $client->rollback();
33 |
34 | echo $response->getHttpStatus() . PHP_EOL;
35 | echo $response->getRequestUrl() . PHP_EOL;
36 | ?>
37 | --EXPECTF--
38 | 200
39 | http://%s/update/extract/?version=2.2&indent=on&wt=xml&literal.id=doc1&capture=p&fmap.p=text
40 |
--------------------------------------------------------------------------------
/tests/017.solrclient_deletebyqueries.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::deleteByQueries() - delete by multiple queries
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $serverOutput = $client->deleteByQueries([
22 | 'id:3675',
23 | 'id:2548'
24 | ]);
25 |
26 | $response = $serverOutput->getResponse();
27 |
28 | print_r($serverOutput->getRawRequest());
29 | print_r($response);
30 |
31 | try {
32 | $client->deleteByQueries(array(0,''));
33 | } catch (SolrIllegalArgumentException $e) {
34 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage());
35 | }
36 | ?>
37 | --EXPECTF--
38 |
39 |
40 | id:3675
41 | id:2548
42 |
43 | SolrObject Object
44 | (
45 | [responseHeader] => SolrObject Object
46 | (
47 | [status] => %d
48 | [QTime] => %d
49 | )
50 |
51 | )
52 | Exception 4000: Query number 1 is not a valid query string
53 |
54 |
--------------------------------------------------------------------------------
/tests/017.solrclient_deletebyquery.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::deleteByQuery() - delete by query
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $serverOutput = $client->deleteByQuery('id:3675');
22 |
23 | $response = $serverOutput->getResponse();
24 |
25 | print_r($serverOutput->getRawRequest());
26 | print_r($response);
27 | ?>
28 | --EXPECTF--
29 |
30 |
31 | id:3675
32 |
33 | SolrObject Object
34 | (
35 | [responseHeader] => SolrObject Object
36 | (
37 | [status] => %d
38 | [QTime] => %d
39 | )
40 |
41 | )
42 |
--------------------------------------------------------------------------------
/tests/017.solrclient_threads.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::threads() - Solr Threads Info
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $response = $client->threads()->getResponse();
22 |
23 | print_r($response->system->threadCount);
24 | ?>
25 | --EXPECTF--
26 | SolrObject Object
27 | (
28 | [current] => %d
29 | [peak] => %d
30 | [daemon] => %d
31 | )
32 |
--------------------------------------------------------------------------------
/tests/018.solrclient_setservlet.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::setServlet() - set different servlet for a certain request type
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $response = $client->ping();
22 | echo $response->getRequestUrl().PHP_EOL;
23 |
24 | $client->setServlet(SolrClient::PING_SERVLET_TYPE, 'select');
25 | $response = $client->ping();
26 | echo $response->getRequestUrl().PHP_EOL;
27 |
28 | ?>
29 | --EXPECTF--
30 | http://%s/solr/collection1/admin/ping/?version=2.2&indent=on&wt=xml
31 | http://%s/solr/collection1/select/?version=2.2&indent=on&wt=xml
32 |
--------------------------------------------------------------------------------
/tests/019.solrclient_clone.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::__clone() - expect exception on clone
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | try {
22 | $failing = clone $client;
23 | } catch (SolrIllegalOperationException $e) {
24 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
25 | }
26 |
27 | ?>
28 | --EXPECTF--
29 | Exception 4001: Cloning of SolrClient objects is currently not supported
--------------------------------------------------------------------------------
/tests/019.solrclient_getdebug.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::getDebug() - Get request debug logs for the last request
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $response = $client->ping();
22 |
23 | $debug = $client->getDebug();
24 |
25 | $lines = explode("\n",$debug);
26 | $print = false;
27 | sort($lines);
28 | foreach ( $lines as $line) {
29 | if ($line == '' ||
30 | FALSE !== strpos($line, 'Trying') ||
31 | 0 === strpos($line, 'Mark bundle') ||
32 | 0 === strpos($line, 'Server') ||
33 | 0 === strpos($line, 'Hostname') ||
34 | 0 === strpos($line, 'TCP_NODELAY') ||
35 | 0 === strpos($line, 'Accept-Encoding') ||
36 | 0 === strpos($line, 'Curl_http_done') ||
37 | 0 === strpos($line, 'processing:')
38 | ) {
39 | $print = false;
40 | } else {
41 | $print = true;
42 | }
43 |
44 | if ($print) {
45 | echo $line . "\n";
46 | }
47 | }
48 | ?>
49 | --EXPECTF--
50 | Accept-Charset: utf-8
51 | Accept: */*
52 | Authorization: Basic %s
53 | Connected to %s
54 | Connection #0 to host %s left intact
55 | Connection: keep-alive
56 | Content-Length: 0
57 | Content-Type: application/xml; charset=UTF-8
58 | HEAD /solr/collection1/admin/ping/?version=2.2&indent=on&wt=xml HTTP/1.1
59 | HTTP/1.1 200 OK
60 | Host: %s:%s
61 | Keep-Alive: 300
62 | User-Agent: %s
63 |
--------------------------------------------------------------------------------
/tests/019.solrclient_serialize.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient - serialization
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | try {
22 | serialize($client);
23 | } catch (SolrIllegalOperationException $e) {
24 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
25 | }
26 |
27 | try {
28 | $serializedString = 'O:10:"SolrClient":0:{}';
29 | unserialize($serializedString);
30 | } catch (SolrIllegalOperationException $e) {
31 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
32 | }
33 |
34 | ?>
35 | --EXPECTF--
36 | Exception 1001: SolrClient objects cannot be serialized or unserialized
37 | Exception 1001: SolrClient objects cannot be serialized or unserialized
38 |
--------------------------------------------------------------------------------
/tests/020.solrdocument_adding_fields.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - checking dimension and magic property sets.
3 | --FILE--
4 | addField('id', 1123);
11 |
12 | $doc->features = "PHP Client Side";
13 | $doc->features = "Fast development cycles";
14 |
15 | $doc['cat'] = 'Software';
16 | $doc['cat'] = 'Custom Search';
17 | $doc->cat = 'Information Technology';
18 |
19 | print_r($doc->toArray());
20 |
21 | ?>
22 | --EXPECT--
23 | Array
24 | (
25 | [document_boost] => 0
26 | [field_count] => 3
27 | [fields] => Array
28 | (
29 | [0] => SolrDocumentField Object
30 | (
31 | [name] => id
32 | [boost] => 0
33 | [values] => Array
34 | (
35 | [0] => 1123
36 | )
37 |
38 | )
39 |
40 | [1] => SolrDocumentField Object
41 | (
42 | [name] => features
43 | [boost] => 0
44 | [values] => Array
45 | (
46 | [0] => PHP Client Side
47 | [1] => Fast development cycles
48 | )
49 |
50 | )
51 |
52 | [2] => SolrDocumentField Object
53 | (
54 | [name] => cat
55 | [boost] => 0
56 | [values] => Array
57 | (
58 | [0] => Software
59 | [1] => Custom Search
60 | [2] => Information Technology
61 | )
62 |
63 | )
64 |
65 | )
66 |
67 | )
68 |
--------------------------------------------------------------------------------
/tests/021.solrdocument_iterator.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - checking Iterator interface implementation
3 | --FILE--
4 | addField('id', 1123);
11 |
12 | $doc->features = "PHP Client Side";
13 | $doc->features = "Fast development cycles";
14 |
15 | $doc['cat'] = 'Software';
16 | $doc['cat'] = 'Custom Search';
17 | $doc->cat = 'Information Technology';
18 |
19 | foreach ($doc as $fieldname => $fieldvalues)
20 | {
21 | print "$fieldname\n";
22 |
23 | print_r($fieldvalues);
24 | }
25 |
26 | ?>
27 | --EXPECT--
28 | id
29 | SolrDocumentField Object
30 | (
31 | [name] => id
32 | [boost] => 0
33 | [values] => Array
34 | (
35 | [0] => 1123
36 | )
37 |
38 | )
39 | features
40 | SolrDocumentField Object
41 | (
42 | [name] => features
43 | [boost] => 0
44 | [values] => Array
45 | (
46 | [0] => PHP Client Side
47 | [1] => Fast development cycles
48 | )
49 |
50 | )
51 | cat
52 | SolrDocumentField Object
53 | (
54 | [name] => cat
55 | [boost] => 0
56 | [values] => Array
57 | (
58 | [0] => Software
59 | [1] => Custom Search
60 | [2] => Information Technology
61 | )
62 |
63 | )
64 |
--------------------------------------------------------------------------------
/tests/022.solrdocument_getInputDocument.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::getInputDocument() - creating SolrInputDocument from SolrDocument
3 | --FILE--
4 | addField('id', 1123);
11 |
12 | $doc->features = "PHP Client Side";
13 | $doc->features = "Fast development cycles";
14 |
15 | $doc['cat'] = 'Software';
16 | $doc['cat'] = 'Custom Search';
17 | $doc->cat = 'Information Technology';
18 |
19 |
20 | $input_doc = $doc->getInputDocument();
21 |
22 | var_dump(get_class($input_doc));
23 |
24 | ?>
25 | --EXPECT--
26 | string(17) "SolrInputDocument"
27 |
--------------------------------------------------------------------------------
/tests/023.solrdocument_merge.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::merge() - merging source document into current document
3 | --FILE--
4 | addField('id', 1123);
13 |
14 | $doc->features = "PHP Client Side";
15 | $doc->features = "Fast development cycles";
16 |
17 | $doc['cat'] = 'Software';
18 | $doc['cat'] = 'Custom Search';
19 | $doc->cat = 'Information Technology';
20 |
21 | $second_doc->addField('cat', 'Lucene Search');
22 |
23 | $second_doc->merge($doc, true);
24 |
25 | print_r($second_doc->toArray());
26 |
27 |
28 | ?>
29 | --EXPECT--
30 | Array
31 | (
32 | [document_boost] => 0
33 | [field_count] => 3
34 | [fields] => Array
35 | (
36 | [0] => SolrDocumentField Object
37 | (
38 | [name] => cat
39 | [boost] => 0
40 | [values] => Array
41 | (
42 | [0] => Software
43 | [1] => Custom Search
44 | [2] => Information Technology
45 | )
46 |
47 | )
48 |
49 | [1] => SolrDocumentField Object
50 | (
51 | [name] => id
52 | [boost] => 0
53 | [values] => Array
54 | (
55 | [0] => 1123
56 | )
57 |
58 | )
59 |
60 | [2] => SolrDocumentField Object
61 | (
62 | [name] => features
63 | [boost] => 0
64 | [values] => Array
65 | (
66 | [0] => PHP Client Side
67 | [1] => Fast development cycles
68 | )
69 |
70 | )
71 |
72 | )
73 |
74 | )
75 |
--------------------------------------------------------------------------------
/tests/023.solrdocument_merge_no_overwrite.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::merge() - merging source document into current document without overwrite
3 | --FILE--
4 | addField('id', 1123);
13 |
14 | $doc->features = "PHP Client Side";
15 | $doc->features = "Fast development cycles";
16 |
17 | $doc['cat'] = 'Software';
18 | $doc['cat'] = 'Custom Search';
19 | $doc->cat = 'Information Technology';
20 |
21 | $second_doc->addField('cat', 'Lucene Search');
22 |
23 | $second_doc->merge($doc, false);
24 |
25 | print_r($second_doc->toArray());
26 |
27 |
28 | ?>
29 | --EXPECT--
30 | Array
31 | (
32 | [document_boost] => 0
33 | [field_count] => 3
34 | [fields] => Array
35 | (
36 | [0] => SolrDocumentField Object
37 | (
38 | [name] => cat
39 | [boost] => 0
40 | [values] => Array
41 | (
42 | [0] => Lucene Search
43 | )
44 |
45 | )
46 |
47 | [1] => SolrDocumentField Object
48 | (
49 | [name] => id
50 | [boost] => 0
51 | [values] => Array
52 | (
53 | [0] => 1123
54 | )
55 |
56 | )
57 |
58 | [2] => SolrDocumentField Object
59 | (
60 | [name] => features
61 | [boost] => 0
62 | [values] => Array
63 | (
64 | [0] => PHP Client Side
65 | [1] => Fast development cycles
66 | )
67 |
68 | )
69 |
70 | )
71 |
72 | )
73 |
--------------------------------------------------------------------------------
/tests/024.solrdocument_child_fetch.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrClient::query() - Query child documents SolrObject (Integ)
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
14 | 'login' => SOLR_SERVER_USERNAME,
15 | 'password' => SOLR_SERVER_PASSWORD,
16 | 'port' => SOLR_SERVER_PORT,
17 | 'path' => SOLR_SERVER_STORE_PATH,
18 | 'wt' => 'xml'
19 | );
20 |
21 | $client = new SolrClient ( $options );
22 |
23 | $query = new SolrQuery ();
24 |
25 | $query->setQuery ( 'id:1 AND {!parent which=$parentFilter}' );
26 | $query->setParam ( 'parentFilter', 'content_type_s:product' );
27 | $query->addFilterQuery('{!parent which=$parentFilter}');
28 |
29 | $query->addField ( '*' );
30 | $query->addField ( '[child parentFilter=$parentFilter]' );
31 |
32 | $query->setStart ( 0 );
33 |
34 | $query->setRows ( 50 );
35 | $queryResponse = $client->query ( $query );
36 |
37 | $response = $queryResponse->getResponse ();
38 | echo "----XML----" . PHP_EOL;
39 | var_dump($response->response->docs[0]->_childDocuments_[0]->id);
40 |
41 | echo "----JSON----" . PHP_EOL;
42 | $options['wt'] = 'json';
43 | $client = new SolrClient ( $options );
44 | $queryResponse = $client->query($query);
45 | $response = $queryResponse->getResponse ();
46 | var_dump($response->response->docs[0]->_childDocuments_[0]->id);
47 | ?>
48 | --EXPECT--
49 | ----XML----
50 | string(9) "IMM-HOW-S"
51 | ----JSON----
52 | string(9) "IMM-HOW-S"
--------------------------------------------------------------------------------
/tests/025.solrdocument_haschilddocuments.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::hasChildDocuments() - Method test
3 | --FILE--
4 | response->docs[0]->hasChildDocuments());
12 | ?>
13 | --EXPECT--
14 | bool(true)
--------------------------------------------------------------------------------
/tests/026.solrdocument_getchilddocscount.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::getChildDocumentsCount() - Method test
3 | --FILE--
4 | response->docs[0]->getChildDocumentsCount());
12 | ?>
13 | --EXPECT--
14 | int(1)
--------------------------------------------------------------------------------
/tests/027.solrdocument_getinputdocument_children.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::getInputDocument() - Where document has child docs
3 | --FILE--
4 | response->docs as $doc)
13 | {
14 | $childrenOfTheInput = $doc->getInputDocument()->getChildDocuments();
15 |
16 | if ($childrenOfTheInput)
17 | {
18 | $firstChild = $childrenOfTheInput[0];
19 | var_dump(get_class($firstChild));
20 | var_dump(current($childrenOfTheInput)->toArray());
21 | }
22 | }
23 |
24 | ?>
25 | --EXPECT--
26 | string(17) "SolrInputDocument"
27 | array(3) {
28 | ["document_boost"]=>
29 | float(0)
30 | ["field_count"]=>
31 | int(1)
32 | ["fields"]=>
33 | array(1) {
34 | [0]=>
35 | object(SolrDocumentField)#9 (3) {
36 | ["name"]=>
37 | string(2) "id"
38 | ["boost"]=>
39 | float(0)
40 | ["values"]=>
41 | array(1) {
42 | [0]=>
43 | string(9) "CHILD_1_1"
44 | }
45 | }
46 | }
47 | }
48 | string(17) "SolrInputDocument"
49 | array(3) {
50 | ["document_boost"]=>
51 | float(0)
52 | ["field_count"]=>
53 | int(1)
54 | ["fields"]=>
55 | array(1) {
56 | [0]=>
57 | object(SolrDocumentField)#10 (3) {
58 | ["name"]=>
59 | string(2) "id"
60 | ["boost"]=>
61 | float(0)
62 | ["values"]=>
63 | array(1) {
64 | [0]=>
65 | string(9) "CHILD_2_1"
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/tests/028.solrdocument_clone.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - clone
3 | --FILE--
4 | response->docs as $doc)
13 | {
14 | $clone = clone $doc;
15 | $childrenOfTheInput = $clone->getInputDocument()->getChildDocuments();
16 |
17 | if ($childrenOfTheInput)
18 | {
19 | $firstChild = $childrenOfTheInput[0];
20 | var_dump(get_class($firstChild));
21 | var_dump(current($childrenOfTheInput)->toArray());
22 | }
23 | }
24 |
25 | ?>
26 | --EXPECTF--
27 | string(17) "SolrInputDocument"
28 | array(3) {
29 | ["document_boost"]=>
30 | float(0)
31 | ["field_count"]=>
32 | int(1)
33 | ["fields"]=>
34 | array(1) {
35 | [0]=>
36 | object(SolrDocumentField)#%d (3) {
37 | ["name"]=>
38 | string(2) "id"
39 | ["boost"]=>
40 | float(0)
41 | ["values"]=>
42 | array(1) {
43 | [0]=>
44 | string(9) "CHILD_1_1"
45 | }
46 | }
47 | }
48 | }
49 | string(17) "SolrInputDocument"
50 | array(3) {
51 | ["document_boost"]=>
52 | float(0)
53 | ["field_count"]=>
54 | int(1)
55 | ["fields"]=>
56 | array(1) {
57 | [0]=>
58 | object(SolrDocumentField)#%d (3) {
59 | ["name"]=>
60 | string(2) "id"
61 | ["boost"]=>
62 | float(0)
63 | ["values"]=>
64 | array(1) {
65 | [0]=>
66 | string(9) "CHILD_2_1"
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/tests/029.solrdocument_serialize.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - clone
3 | --SKIPIF--
4 | = 80100) die("skip PHP < 8.1 only"); ?>
5 | --FILE--
6 | response->docs[1];
15 |
16 | $serializedString = serialize($doc);
17 | print_r($serializedString);
18 | echo PHP_EOL;
19 | print_r(unserialize($serializedString)->toArray());
20 | ?>
21 | --EXPECT--
22 | C:12:"SolrDocument":172:{
23 |
24 |
25 |
26 | parent_2
27 |
28 |
29 |
30 | }
31 | Array
32 | (
33 | [document_boost] => 0
34 | [field_count] => 1
35 | [fields] => Array
36 | (
37 | [0] => SolrDocumentField Object
38 | (
39 | [name] => id
40 | [boost] => 0
41 | [values] => Array
42 | (
43 | [0] => parent_2
44 | )
45 |
46 | )
47 |
48 | )
49 |
50 | )
51 |
--------------------------------------------------------------------------------
/tests/029.solrdocument_serialize_php81.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - clone
3 | --SKIPIF--
4 |
5 | --FILE--
6 | response->docs[1];
15 |
16 | $serializedString = serialize($doc);
17 | print_r($serializedString);
18 | echo PHP_EOL;
19 | print_r(unserialize($serializedString)->toArray());
20 | ?>
21 | --EXPECT--
22 | O:12:"SolrDocument":1:{s:3:"xml";s:172:"
23 |
24 |
25 |
26 | parent_2
27 |
28 |
29 |
30 | ";}
31 | Array
32 | (
33 | [document_boost] => 0
34 | [field_count] => 1
35 | [fields] => Array
36 | (
37 | [0] => SolrDocumentField Object
38 | (
39 | [name] => id
40 | [boost] => 0
41 | [values] => Array
42 | (
43 | [0] => parent_2
44 | )
45 |
46 | )
47 |
48 | )
49 |
50 | )
51 |
--------------------------------------------------------------------------------
/tests/030.solrdocument_magic.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - magic __isset/__unset/__get/__set
3 | --FILE--
4 | check = 1;
11 | $doc->deleteMe = 1;
12 |
13 | var_dump(isset($doc->check));
14 | var_dump(isset($doc->doesNotExist));
15 |
16 |
17 | var_dump(isset($doc->deleteMe));
18 | unset($doc->deleteMe);
19 | var_dump(isset($doc->deleteMe));
20 |
21 | $doc->addField('id', 1);
22 |
23 | var_dump($doc->id instanceof SolrDocumentField);
24 | ?>
25 | --EXPECTF--
26 | bool(true)
27 | bool(false)
28 | bool(true)
29 | bool(false)
30 | bool(true)
--------------------------------------------------------------------------------
/tests/031.solrdocument_clear.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::clear - Remove all fields from the document
3 | --FILE--
4 | check = 1;
16 |
17 | var_dump($doc->getFieldCount());
18 | $doc->clear();
19 | var_dump($doc->getFieldCount());
20 | ?>
21 | --EXPECTF--
22 | int(1)
23 | int(0)
--------------------------------------------------------------------------------
/tests/032.solrdocument_fieldexists.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::fieldExists
3 | --FILE--
4 | check = 1;
16 |
17 | var_dump($doc->fieldExists('check'));
18 | var_dump($doc->fieldExists('nonExistingField'));
19 | ?>
20 | --EXPECT--
21 | bool(true)
22 | bool(false)
--------------------------------------------------------------------------------
/tests/033.solrdocument_sort.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::sort - Sort Document fields
3 | --FILE--
4 | addField('z1', 'z1val');
11 | $doc->addField('z1', 'z1val2');
12 | $doc->addField('z1', 'z1val3');
13 |
14 | $doc->addField('id', 334455);
15 | $doc->addField('cat', 'Software');
16 | $doc->addField('cat', 'Lucene');
17 |
18 | separator('unsorted');
19 | print_r($doc->getFieldNames());
20 |
21 | separator('field ASC');
22 | $doc->sort(SolrDocument::SORT_FIELD_NAME, SolrDocument::SORT_ASC);
23 | print_r($doc->getFieldNames());
24 | separator('field DESC');
25 | $doc->sort(SolrDocument::SORT_FIELD_NAME, SolrDocument::SORT_DESC);
26 | print_r($doc->getFieldNames());
27 |
28 | separator('value ASC');
29 | $doc->sort(SolrDocument::SORT_FIELD_VALUE_COUNT, SolrDocument::SORT_ASC);
30 | print_r($doc->getFieldNames());
31 | separator('value DESC');
32 | $doc->sort(SolrDocument::SORT_FIELD_VALUE_COUNT, SolrDocument::SORT_DESC);
33 | print_r($doc->getFieldNames());
34 | ?>
35 | --EXPECT--
36 | =================================== unsorted ===================================
37 | Array
38 | (
39 | [0] => z1
40 | [1] => id
41 | [2] => cat
42 | )
43 | ================================== field ASC ===================================
44 | Array
45 | (
46 | [0] => cat
47 | [1] => id
48 | [2] => z1
49 | )
50 | ================================== field DESC ==================================
51 | Array
52 | (
53 | [0] => z1
54 | [1] => id
55 | [2] => cat
56 | )
57 | ================================== value ASC ===================================
58 | Array
59 | (
60 | [0] => id
61 | [1] => cat
62 | [2] => z1
63 | )
64 | ================================== value DESC ==================================
65 | Array
66 | (
67 | [0] => z1
68 | [1] => cat
69 | [2] => id
70 | )
71 |
--------------------------------------------------------------------------------
/tests/034.solrdocument_deletefield.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::deleteField
3 | --FILE--
4 | check = 1;
11 |
12 | var_dump($doc->getFieldCount());
13 | $doc->deleteField('check');
14 | var_dump($doc->getFieldCount());
15 | ?>
16 | --EXPECTF--
17 | int(1)
18 | int(0)
--------------------------------------------------------------------------------
/tests/035.solrdocument_getfieldnames.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::getFieldNames
3 | --FILE--
4 | addField('id', 334455);
10 | $doc->addField('manu_id_s', 'apache');
11 | $doc->addField('cat', 'Software');
12 |
13 | print_r($doc->getFieldNames());
14 | ?>
15 | --EXPECT--
16 | Array
17 | (
18 | [0] => id
19 | [1] => manu_id_s
20 | [2] => cat
21 | )
22 |
--------------------------------------------------------------------------------
/tests/036.solrdocument_array_access.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - Array Access
3 | --FILE--
4 | addField('id', 334455);
10 | $doc->addField('manu_id_s', 'apache');
11 | // set
12 | $doc['cat'] = 'Software';
13 |
14 | // get
15 | var_dump($doc['cat']->values[0]);
16 |
17 | // exists
18 | var_dump(isset($doc['cat']));
19 |
20 | // unset
21 | unset($doc['cat']);
22 | print_r($doc->toArray());
23 | ?>
24 | --EXPECT--
25 | string(8) "Software"
26 | bool(true)
27 | Array
28 | (
29 | [document_boost] => 0
30 | [field_count] => 2
31 | [fields] => Array
32 | (
33 | [0] => SolrDocumentField Object
34 | (
35 | [name] => id
36 | [boost] => 0
37 | [values] => Array
38 | (
39 | [0] => 334455
40 | )
41 |
42 | )
43 |
44 | [1] => SolrDocumentField Object
45 | (
46 | [name] => manu_id_s
47 | [boost] => 0
48 | [values] => Array
49 | (
50 | [0] => apache
51 | )
52 |
53 | )
54 |
55 | )
56 |
57 | )
58 |
--------------------------------------------------------------------------------
/tests/037.solrdocument_getfield.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument::getField
3 | --FILE--
4 | check = 1;
16 |
17 | var_dump($doc->getField('check') instanceof SolrDocumentField);
18 | ?>
19 | --EXPECT--
20 | bool(true)
--------------------------------------------------------------------------------
/tests/041.solrobject_illegal_operation.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrObject - checking illegal operation of modifying object
3 | --FILE--
4 | email = "iekpo@php.net";
11 | } catch (Exception $e) {
12 | var_dump($e->getCode());
13 | var_dump($e->getMessage());
14 | }
15 |
16 | try {
17 | $solrObject['usingOffset'] = 'test';
18 | } catch (SolrIllegalOperationException $e) {
19 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
20 | }
21 |
22 | try {
23 | $solrObject['newprop2_dimension_access'] = 'test';
24 | } catch (SolrIllegalOperationException $e) {
25 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
26 | }
27 |
28 | // unset
29 | try {
30 | unset($solrObject->responseHeader);
31 | } catch (SolrIllegalOperationException $e) {
32 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
33 | }
34 |
35 | try {
36 | unset($solrObject['responseHeader']);
37 | } catch (SolrIllegalOperationException $e) {
38 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
39 | }
40 |
41 | ?>
42 | --EXPECTF--
43 | int(1006)
44 | string(83) "SolrObject instances are read-only. Properties cannot be added, updated or removed."
45 |
46 | Warning: main(): Attempting to set value for [usingOffset] property in a SolrObject instance in %s on line %d
47 | Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed.
48 |
49 | Warning: main(): Attempting to set value for [newprop2_dimension_access] property in a SolrObject instance in %s on line %d
50 | Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed.
51 | Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed.
52 |
53 | Warning: main(): Attempting to remove [responseHeader] property in a SolrObject instance in %s on line %d
54 | Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed.
55 |
--------------------------------------------------------------------------------
/tests/042.solrobject_magic_property.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrObject - testing the magic property access
3 | --FILE--
4 | system->threadDump->thread->stackTrace);
13 |
14 | ?>
15 | --EXPECT--
16 | Array
17 | (
18 | [0] => java.net.PlainSocketImpl.socketAccept(Native Method)
19 | [1] => java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
20 | [2] => java.net.ServerSocket.implAccept(ServerSocket.java:450)
21 | [3] => java.net.ServerSocket.accept(ServerSocket.java:421)
22 | [4] => org.apache.catalina.core.StandardServer.await(StandardServer.java:389)
23 | [5] => org.apache.catalina.startup.Catalina.await(Catalina.java:642)
24 | [6] => org.apache.catalina.startup.Catalina.start(Catalina.java:602)
25 | [7] => sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
26 | [8] => sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
27 | [9] => sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
28 | [10] => java.lang.reflect.Method.invoke(Method.java:585)
29 | [11] => org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
30 | [12] => org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
31 | )
32 |
--------------------------------------------------------------------------------
/tests/043.solrobject_magic_properties.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrObject - test property access
3 | --FILE--
4 | responseHeader;
13 |
14 | $system = $solrObject->system;
15 |
16 | var_dump(isset($solrObject['system']));
17 | var_dump(property_exists($solrObject, 'system'));
18 | ?>
19 | --EXPECT--
20 | bool(true)
21 | bool(true)
--------------------------------------------------------------------------------
/tests/046.solrobject_getpropertynames.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrObject - SolrObject::getPropertyNames()
3 | --FILE--
4 | getPropertyNames());
9 |
10 | require_once "bootstrap.inc";
11 |
12 | $xml_reponse = file_get_contents(EXAMPLE_RESPONSE_XML_1);
13 |
14 | $solrObject = SolrUtils::digestXMLResponse($xml_reponse);
15 |
16 | var_dump($solrObject->getPropertyNames());
17 | ?>
18 | --EXPECT--
19 | array(0) {
20 | }
21 | array(2) {
22 | [0]=>
23 | string(14) "responseHeader"
24 | [1]=>
25 | string(6) "system"
26 | }
27 |
--------------------------------------------------------------------------------
/tests/047.solrobject_offsetExists.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrObject::offsetExists
3 | --FILE--
4 |
18 | --EXPECT--
19 | bool(false)
20 | bool(true)
21 | bool(false)
--------------------------------------------------------------------------------
/tests/050.solrinputdocument_addchilddocument_01.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::addChildDocument() - add child document
3 | --FILE--
4 | addField('id', 1123);
13 | $doc->addField('features', "PHP Client Side");
14 | $doc->addField('features', "Fast development cycles");
15 | $doc->cat = 'Information Technology';
16 |
17 | $secondDoc->addField('cat', 'Lucene Search');
18 | $secondDoc->cat = 'Custom Search';
19 |
20 | $doc->addChildDocument($secondDoc);
21 |
22 | var_dump($doc->hasChildDocuments(), $secondDoc->hasChildDocuments());
23 |
24 | $childs = $doc->getChildDocuments();
25 | print_r($childs[0]->getField('cat'));
26 |
27 | ?>
28 | --EXPECT--
29 | bool(true)
30 | bool(false)
31 | SolrDocumentField Object
32 | (
33 | [name] => cat
34 | [boost] => 0
35 | [values] => Array
36 | (
37 | [0] => Lucene Search
38 | )
39 |
40 | )
41 |
--------------------------------------------------------------------------------
/tests/050.solrinputdocument_addchilddocument_02_error.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::addChildDocument()/SolrInputDocument::addChildDocuments() - Expected SolrIllegalArgumentException
3 | --FILE--
4 | addField('id', 1123);
14 | $doc->addField('features', "PHP Client Side");
15 | $doc->addField('features', "Fast development cycles");
16 | $doc->cat = 'Information Technology';
17 | try {
18 | $doc->addChildDocument($child1);
19 | } catch (SolrIllegalArgumentException $e) {
20 | echo $e->getMessage(). PHP_EOL;
21 | }
22 |
23 | $children = array($child1, $child2);
24 | try {
25 | $doc->addChildDocuments($children);
26 | } catch (SolrIllegalArgumentException $e) {
27 | echo $e->getMessage(). PHP_EOL;
28 | }
29 | ?>
30 | --EXPECT--
31 | Child document has no fields
32 | SolrInputDocument number 1 has no fields
--------------------------------------------------------------------------------
/tests/051.solrinputdocument_getchilddocuments.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::getChildDocuments() - test
3 | --FILE--
4 | addField('id', 1123);
13 | $doc->addField('features', "PHP Client Side");
14 | $doc->addField('features', "Fast development cycles");
15 | $doc->cat = 'Information Technology';
16 |
17 | $secondDoc->addField('cat', 'Lucene Search');
18 | $secondDoc->cat = 'Custom Search';
19 |
20 | $doc->addChildDocument($secondDoc);
21 |
22 | $childs = $doc->getChildDocuments();
23 | print_r($childs[0]->getField('cat'));
24 |
25 | ?>
26 | --EXPECT--
27 | SolrDocumentField Object
28 | (
29 | [name] => cat
30 | [boost] => 0
31 | [values] => Array
32 | (
33 | [0] => Lucene Search
34 | )
35 |
36 | )
--------------------------------------------------------------------------------
/tests/052.solrinputdocument_haschilddocuments.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::hasChildDocuments() - test
3 | --FILE--
4 | addField('id', 1123);
13 | $doc->addField('features', "PHP Client Side");
14 | $doc->addField('features', "Fast development cycles");
15 | $doc->cat = 'Information Technology';
16 |
17 | $secondDoc->addField('cat', 'Lucene Search');
18 | $secondDoc->cat = 'Custom Search';
19 |
20 | $doc->addChildDocument($secondDoc);
21 |
22 | var_dump($doc->hasChildDocuments());
23 | var_dump($secondDoc->hasChildDocuments());
24 | ?>
25 | --EXPECT--
26 | bool(true)
27 | bool(false)
--------------------------------------------------------------------------------
/tests/053.solrinputdocument_getchilddocumentscount.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::getChildDocumentsCount() - test
3 | --FILE--
4 | addField('id', 1123);
13 | $doc->addField('features', "PHP Client Side");
14 | $doc->addField('features', "Fast development cycles");
15 | $doc->cat = 'Information Technology';
16 |
17 | $secondDoc->addField('cat', 'Lucene Search');
18 | $secondDoc->cat = 'Custom Search';
19 |
20 | $doc->addChildDocument($secondDoc);
21 |
22 | var_dump($doc->getChildDocumentsCount());
23 | var_dump($secondDoc->getChildDocumentsCount());
24 | ?>
25 | --EXPECT--
26 | int(1)
27 | int(0)
--------------------------------------------------------------------------------
/tests/054.solrinputdocument_addchilddocuments.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::addChildDocuments() - add child documents
3 | --FILE--
4 | addField('id', 1123);
14 | $doc->addField('features', "PHP Client Side");
15 | $doc->addField('features', "Fast development cycles");
16 | $doc->cat = 'Information Technology';
17 |
18 | $doc2->addField('cat', 'Lucene Search');
19 | $doc2->cat = 'Custom Search';
20 |
21 | $doc2->addField('cat', 'Lucene Search');
22 | $doc2->cat = 'Custom Search';
23 |
24 | $doc3->addField('cat', 'Lucene Search');
25 | $doc3->cat = 'Custom Search';
26 | $docs = array($doc2, $doc3);
27 | $doc->addChildDocuments($docs);
28 |
29 | var_dump($doc->getChildDocumentsCount());
30 | ?>
31 | --EXPECT--
32 | int(2)
--------------------------------------------------------------------------------
/tests/055.solrinputdocument_serialization.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument - serialize/unserialize Exception
3 | --FILE--
4 | getMessage().PHP_EOL;
14 | }
15 | ?>
16 | --EXPECT--
17 | SolrInputDocument objects cannot be serialized or unserialized
--------------------------------------------------------------------------------
/tests/056.solrinputdocument_toArray.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::toArray - Array conversion
3 | --FILE--
4 | addField('field_1', 4, 3.4);
11 | $doc->addField('field_2', 1);
12 |
13 | print_r($doc->toArray());
14 | ?>
15 | --EXPECT--
16 | Array
17 | (
18 | [document_boost] => 0
19 | [field_count] => 2
20 | [fields] => Array
21 | (
22 | [0] => SolrDocumentField Object
23 | (
24 | [name] => field_1
25 | [boost] => 3.4
26 | [values] => Array
27 | (
28 | [0] => 4
29 | )
30 |
31 | )
32 |
33 | [1] => SolrDocumentField Object
34 | (
35 | [name] => field_2
36 | [boost] => 0
37 | [values] => Array
38 | (
39 | [0] => 1
40 | )
41 |
42 | )
43 |
44 | )
45 |
46 | )
47 |
--------------------------------------------------------------------------------
/tests/057.solrinputdocument_clone.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument - clone
3 | --FILE--
4 | setBoost(4);
9 | $doc->addField('id', 334455);
10 | $doc->addField('cat', 'Software', 4);
11 | $doc->addField('cat', 'Lucene');
12 |
13 | $doc2 = clone $doc;
14 | $doc2->deleteField('id');
15 | $doc2->addField('id', '88', 8);
16 |
17 | print_r($doc->toArray());
18 | print_r($doc2->toArray());
19 | ?>
20 | --EXPECTF--
21 | Array
22 | (
23 | [document_boost] => 4
24 | [field_count] => 2
25 | [fields] => Array
26 | (
27 | [0] => SolrDocumentField Object
28 | (
29 | [name] => id
30 | [boost] => 0
31 | [values] => Array
32 | (
33 | [0] => 334455
34 | )
35 |
36 | )
37 |
38 | [1] => SolrDocumentField Object
39 | (
40 | [name] => cat
41 | [boost] => 4
42 | [values] => Array
43 | (
44 | [0] => Software
45 | [1] => Lucene
46 | )
47 |
48 | )
49 |
50 | )
51 |
52 | )
53 | Array
54 | (
55 | [document_boost] => 4
56 | [field_count] => 2
57 | [fields] => Array
58 | (
59 | [0] => SolrDocumentField Object
60 | (
61 | [name] => cat
62 | [boost] => 4
63 | [values] => Array
64 | (
65 | [0] => Software
66 | [1] => Lucene
67 | )
68 |
69 | )
70 |
71 | [1] => SolrDocumentField Object
72 | (
73 | [name] => id
74 | [boost] => 8
75 | [values] => Array
76 | (
77 | [0] => 88
78 | )
79 |
80 | )
81 |
82 | )
83 |
84 | )
85 |
--------------------------------------------------------------------------------
/tests/058.solrinputdocument_deletefield.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::deleteField - Delete a field from SolrInputDocument
3 | --FILE--
4 | addField('id', 334455);
10 | $doc->addField('cat', 'Software');
11 | $doc->addField('cat', 'Lucene');
12 | $doc->addField('deleteme', 'Lucene');
13 | $doc->deleteField('deleteme');
14 |
15 | print_r($doc->toArray());
16 | ?>
17 | --EXPECT--
18 | Array
19 | (
20 | [document_boost] => 0
21 | [field_count] => 2
22 | [fields] => Array
23 | (
24 | [0] => SolrDocumentField Object
25 | (
26 | [name] => id
27 | [boost] => 0
28 | [values] => Array
29 | (
30 | [0] => 334455
31 | )
32 |
33 | )
34 |
35 | [1] => SolrDocumentField Object
36 | (
37 | [name] => cat
38 | [boost] => 0
39 | [values] => Array
40 | (
41 | [0] => Software
42 | [1] => Lucene
43 | )
44 |
45 | )
46 |
47 | )
48 |
49 | )
50 |
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_clear.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::clear - Clear document fields
3 | --FILE--
4 | addField('id', 334455);
11 | $doc->addField('cat', 'Software');
12 | $doc->addField('cat', 'Lucene');
13 | $doc->addField('z1', 'z1val');
14 |
15 | $doc->clear();
16 |
17 | var_dump($doc->toArray());
18 | ?>
19 | --EXPECT--
20 | array(3) {
21 | ["document_boost"]=>
22 | float(0)
23 | ["field_count"]=>
24 | int(0)
25 | ["fields"]=>
26 | array(0) {
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_fieldexists.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::fieldExists
3 | --FILE--
4 | addField('id', 1123);
10 |
11 | var_dump($doc->fieldExists('id'));
12 | var_dump($doc->fieldExists('features'));
13 | ?>
14 | --EXPECT--
15 | bool(true)
16 | bool(false)
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_getboost.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::getBoost - Test document fieldnames
3 | --FILE--
4 | setBoost(4);
9 | var_dump($doc->getBoost());
10 | ?>
11 | --EXPECT--
12 | float(4)
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_getfield.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::getField
3 | --FILE--
4 | addField('id', 123);
10 | $doc->addField('cat', 'Software');
11 |
12 | var_dump($doc->getField('id'));
13 | var_dump($doc->getField('non_existing_field'));
14 | ?>
15 | --EXPECT--
16 | object(SolrDocumentField)#2 (3) {
17 | ["name"]=>
18 | string(2) "id"
19 | ["boost"]=>
20 | float(0)
21 | ["values"]=>
22 | array(1) {
23 | [0]=>
24 | string(3) "123"
25 | }
26 | }
27 | bool(false)
28 |
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_getfieldcount.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::getFieldCount
3 | --FILE--
4 | addField('id', 123);
10 | $doc->addField('cat', 'Software');
11 | $doc->addField('cat', 'Search Server');
12 | $doc->addField('features', 'Software');
13 |
14 | var_dump($doc->getFieldCount());
15 |
16 | ?>
17 | --EXPECT--
18 | int(3)
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_getfieldnames.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::getFieldNames - Test document fieldnames
3 | --FILE--
4 | addField('id', 334455);
10 | $doc->addField('manu_id_s', 'apache');
11 | $doc->addField('cat', 'Software');
12 |
13 | print_r($doc->getFieldNames());
14 | ?>
15 | --EXPECT--
16 | Array
17 | (
18 | [0] => id
19 | [1] => manu_id_s
20 | [2] => cat
21 | )
22 |
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_set_getfieldboost.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::getFieldBoost
3 | --FILE--
4 | addField('id', 123);
10 | $doc->addField('cat', 'Software');
11 |
12 | $doc->setFieldBoost('cat', 2.1);
13 | var_dump($doc->getFieldBoost('cat'));
14 |
15 | ?>
16 | --EXPECT--
17 | float(2.1)
--------------------------------------------------------------------------------
/tests/059.solrinputdocument_setversion.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrInputDocument::setVersion - Set document version
3 | --SKIPIF--
4 |
5 | --FILE--
6 | addField('id', 'IW-02');
13 |
14 | $doc->setVersion(SolrInputDocument::VERSION_ASSERT_EXISTS);
15 | var_dump($doc->getVersion());
16 |
17 | $doc->setVersion(SolrInputDocument::VERSION_ASSERT_NOT_EXISTS);
18 | var_dump($doc->getVersion());
19 |
20 | $doc->setVersion(SolrInputDocument::VERSION_ASSERT_NONE);
21 | var_dump($doc->getVersion());
22 |
23 | $doc->setVersion(1498562624496861184);
24 | var_dump($doc->getVersion());
25 |
26 | try {
27 | $doc->setVersion('AAAA-3333');
28 | } catch (SolrIllegalArgumentException $e) {
29 | echo $e->getMessage();
30 | } catch (TypeError $e) {
31 | echo $e->getMessage();
32 | }
33 |
34 | ?>
35 | --EXPECTF--
36 | int(1)
37 | int(-1)
38 | int(0)
39 | int(1498562624496861184)
40 | %slrInputDocument::setVersion()%s, string given
41 |
--------------------------------------------------------------------------------
/tests/060.solrquery_comon_query_params.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery - testing CommonQueryParameters
3 | --FILE--
4 | getQuery(),
10 | $query->getTimeAllowed(),
11 | $query->getStart(),
12 | $query->getRows(),
13 | $query->getFields(),
14 | $query->getFilterQueries(),
15 | $query->getSortFields()
16 | );
17 | $nullOutput = ob_get_clean();
18 |
19 | $query->setParam('a', 1);
20 | $query->setParam('b', 2);
21 | $query->setParam('c', 3);
22 |
23 | $query->setStart(4)->setQuery('solr')->setTimeAllowed(500)->setRows(17);
24 |
25 | $query->addField('israel')->addField('joshua')->addField('june');
26 |
27 | $query->addSortField('cat', SolrQuery::ORDER_ASC);
28 |
29 | $query->addFilterQuery('solr')->addFilterQuery('solr1')->addFilterQuery('solr2');
30 |
31 | $query
32 | ->setShowDebugInfo(true)
33 | ->setExplainOther('id:SOL*')
34 | ->setOmitHeader(false)
35 | ->setEchoHandler(true)
36 | ->setEchoParams('all')
37 | ;
38 |
39 | echo $query . PHP_EOL . PHP_EOL;
40 |
41 | var_dump(
42 | $query->getQuery(),
43 | $query->getTimeAllowed(),
44 | $query->getStart(),
45 | $query->getRows(),
46 | $query->getFields(),
47 | $query->getFilterQueries(),
48 | $query->getSortFields()
49 | );
50 |
51 | echo $nullOutput;
52 | ?>
53 | --EXPECT--
54 | a=1&b=2&c=3&start=4&q=solr&timeAllowed=500&rows=17&fl=israel,joshua,june&sort=cat asc&fq=solr&fq=solr1&fq=solr2&debugQuery=true&explainOther=id:SOL*&omitHeader=false&echoHandler=true&echoParams=all
55 |
56 | string(4) "solr"
57 | int(500)
58 | int(4)
59 | int(17)
60 | array(3) {
61 | [0]=>
62 | string(6) "israel"
63 | [1]=>
64 | string(6) "joshua"
65 | [2]=>
66 | string(4) "june"
67 | }
68 | array(3) {
69 | [0]=>
70 | string(4) "solr"
71 | [1]=>
72 | string(5) "solr1"
73 | [2]=>
74 | string(5) "solr2"
75 | }
76 | array(1) {
77 | [0]=>
78 | string(7) "cat asc"
79 | }
80 | NULL
81 | NULL
82 | NULL
83 | NULL
84 | NULL
85 | NULL
86 | NULL
--------------------------------------------------------------------------------
/tests/061.solrquery_simpleFacetParameters.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery - testing SimpleFacetParameters
3 | --FILE--
4 | setFacet(0);
9 |
10 | $query->addFacetField('israel')->addFacetField('israel2');
11 |
12 | $query->addFacetQuery('silk')->addFacetQuery('name:june');
13 |
14 | $query->setFacetPrefix('A')->setFacetPrefix('C', 'june');
15 |
16 | $query->setFacetSort(1)->setFacetSort(0, 'june');
17 |
18 | $query->setFacetLimit(98)->setFacetLimit(44, 'june');
19 |
20 | $query->setFacetOffset(110)->setFacetOffset(12, 'june');
21 |
22 | $query->setFacetMinCount(4)->setFacetMinCount(30, 'june');
23 |
24 | $query->setFacetMissing(1)->setFacetMissing(0, 'june');
25 |
26 | $query->setFacetMethod('enum')->setFacetMethod('fc', 'june');
27 |
28 | $query->setFacetEnumCacheMinDefaultFrequency(25);
29 |
30 | echo $query . PHP_EOL . PHP_EOL;
31 |
32 | var_dump(
33 | $query->getFacet(),
34 | $query->getFacetFields(),
35 | $query->getFacetQueries(),
36 | $query->getFacetPrefix(),
37 | $query->getFacetPrefix('june'),
38 | $query->getFacetSort(),
39 | $query->getFacetSort('june'),
40 | $query->getFacetLimit(),
41 | $query->getFacetLimit('june'),
42 | $query->getFacetOffset(),
43 | $query->getFacetOffset('june'),
44 | $query->getFacetMinCount(),
45 | $query->getFacetMinCount('june'),
46 | $query->getFacetMissing(),
47 | $query->getFacetMissing('june'),
48 | $query->getFacetMethod(),
49 | $query->getFacetMethod('june')
50 | );
51 | ?>
52 | --EXPECTF--
53 | facet=false&facet.field=israel&facet.field=israel2&facet.query=silk&facet.query=name:june&facet.prefix=A&f.june.facet.prefix=C&facet.sort=count&f.june.facet.sort=index&facet.limit=98&f.june.facet.limit=44&facet.offset=110&f.june.facet.offset=12&facet.mincount=4&f.june.facet.mincount=30&facet.missing=true&f.june.facet.missing=false&facet.method=enum&f.june.facet.method=fc&facet.enum.cache.minDf=25
54 |
55 | bool(false)
56 | array(2) {
57 | [0]=>
58 | string(6) "israel"
59 | [1]=>
60 | string(7) "israel2"
61 | }
62 | array(2) {
63 | [0]=>
64 | string(4) "silk"
65 | [1]=>
66 | string(9) "name:june"
67 | }
68 | string(1) "A"
69 | string(1) "C"
70 | int(1)
71 | int(0)
72 | int(98)
73 | int(44)
74 | int(110)
75 | int(12)
76 | int(4)
77 | int(30)
78 | bool(true)
79 | bool(false)
80 | string(4) "enum"
81 | string(2) "fc"
82 |
--------------------------------------------------------------------------------
/tests/064.solrquery_StatsComponent.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery - testing StatsComponent
3 | --FILE--
4 | getStats(),
10 | $query->getStatsFields(),
11 | $query->getStatsFacets()
12 | );
13 |
14 | $nullOutput = ob_get_clean();
15 |
16 | $query->setStats(0);
17 |
18 | $query
19 | ->addStatsField('hello')
20 | ->removeStatsField('hello')
21 | ->addStatsField('june')
22 | ->addStatsField('july')
23 | ;
24 |
25 | $query
26 | ->addStatsFacet('world')
27 | ->removeStatsFacet('world')
28 | ->addStatsFacet('pear')
29 | ->addStatsFacet('pecl')
30 | ;
31 |
32 | echo $query . PHP_EOL . PHP_EOL;
33 |
34 | var_dump(
35 | $query->getStats(),
36 | $query->getStatsFields(),
37 | $query->getStatsFacets()
38 | );
39 | echo $nullOutput;
40 | ?>
41 | --EXPECTF--
42 | stats=false&stats.field=june&stats.field=july&stats.facet=pear&stats.facet=pecl
43 |
44 | bool(false)
45 | array(2) {
46 | [0]=>
47 | string(4) "june"
48 | [1]=>
49 | string(4) "july"
50 | }
51 | array(2) {
52 | [0]=>
53 | string(4) "pear"
54 | [1]=>
55 | string(4) "pecl"
56 | }
57 | NULL
58 | NULL
59 | NULL
--------------------------------------------------------------------------------
/tests/066.solrquery_TermsComponent.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery - testing TermsComponent
3 | --FILE--
4 | getTerms(),
11 | $query->getTermsField(),
12 | $query->getTermsLowerBound(),
13 | $query->getTermsUpperBound(),
14 | $query->getTermsIncludeLowerBound(),
15 | $query->getTermsIncludeUpperBound(),
16 | $query->getTermsMinCount(),
17 | $query->getTermsMaxCount(),
18 | $query->getTermsPrefix(),
19 | $query->getTermsLimit(),
20 | $query->getTermsReturnRaw(),
21 | $query->getTermsSort()
22 | );
23 | };
24 |
25 | ob_start();
26 | $dumpVars();
27 | $nullOutput = ob_get_clean();
28 |
29 | $query->setTerms(true);
30 |
31 | $query->setTermsField('israel');
32 |
33 | $query->setTermsLowerBound('june');
34 |
35 | $query->setTermsUpperBound('joshua');
36 |
37 | $query->setTermsIncludeLowerBound(false);
38 |
39 | $query->setTermsIncludeUpperBound(0);
40 |
41 | $query->setTermsMinCount(50);
42 |
43 | $query->setTermsMaxCount(200);
44 |
45 | $query->setTermsPrefix('A');
46 |
47 | $query->setTermsLimit(45);
48 |
49 | $query->setTermsReturnRaw(false);
50 |
51 | $query->setTermsSort(SolrQuery::TERMS_SORT_INDEX);
52 |
53 | echo $query . PHP_EOL . PHP_EOL;
54 |
55 | $dumpVars();
56 |
57 |
58 | $query->setTermsSort(SolrQuery::TERMS_SORT_COUNT);
59 | echo PHP_EOL . $query . PHP_EOL . PHP_EOL;
60 |
61 | var_dump(
62 | $query->getTermsSort()
63 | );
64 |
65 | echo $nullOutput;
66 | ?>
67 | --EXPECTF--
68 | terms=true&terms.fl=israel&terms.lower=june&terms.upper=joshua&terms.lower.incl=false&terms.upper.incl=false&terms.mincount=50&terms.maxcount=200&terms.prefix=A&terms.limit=45&terms.raw=false&terms.sort=index
69 |
70 | bool(true)
71 | string(6) "israel"
72 | string(4) "june"
73 | string(6) "joshua"
74 | bool(false)
75 | bool(false)
76 | int(50)
77 | int(200)
78 | string(1) "A"
79 | int(45)
80 | bool(false)
81 | int(0)
82 |
83 | terms=true&terms.fl=israel&terms.lower=june&terms.upper=joshua&terms.lower.incl=false&terms.upper.incl=false&terms.mincount=50&terms.maxcount=200&terms.prefix=A&terms.limit=45&terms.raw=false&terms.sort=count
84 |
85 | int(1)
86 | NULL
87 | NULL
88 | NULL
89 | NULL
90 | NULL
91 | NULL
92 | NULL
93 | NULL
94 | NULL
95 | NULL
96 | NULL
97 | NULL
98 |
--------------------------------------------------------------------------------
/tests/067.solrquery__construct.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery::_construct - Throws exception on illegal Argument
3 | --FILE--
4 | getMessage();
10 | } catch (TypeError $e) {
11 | echo $e->getMessage();
12 | }
13 | ?>
14 | --EXPECTF--
15 | SolrQuery::__construct()%s string, %s given
16 |
--------------------------------------------------------------------------------
/tests/068.solrquery_parameters_error.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery - Invalid Parameters thorws exception Throws exception on illegal Argument
3 | --FILE--
4 | setQuery('');
12 | }catch (SolrIllegalArgumentException $e)
13 | {
14 | echo $e->getMessage().PHP_EOL;
15 | try {
16 | // simple list
17 | $query->addField('');
18 | } catch (SolrIllegalArgumentException $e) {
19 | echo $e->getMessage().PHP_EOL;
20 | try {
21 | // argument list
22 | $query->addSortField('');
23 | } catch (SolrIllegalArgumentException $e) {
24 | echo $e->getMessage().PHP_EOL;
25 | try {
26 | $params->addParam('',1);
27 | } catch (Exception $e) {
28 | echo $e->getMessage().PHP_EOL;
29 | }
30 | }
31 | }
32 | }
33 | ?>
34 | --EXPECT--
35 | Invalid parameter value
36 | Invalid parameter value
37 | Invalid parameter value
38 | Invalid parameter name
39 |
--------------------------------------------------------------------------------
/tests/070.solrquery_collapse.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery::collapse - Collapse Using a SolrCollapseFunction
3 | --FILE--
4 | setMax(5);
9 |
10 | $query->collapse($collapseFunction);
11 |
12 | echo $query;
13 | ?>
14 | --EXPECTF--
15 | q=lucene&fq={!collapse field=ISBN max=5}
16 |
--------------------------------------------------------------------------------
/tests/071.solrquery_collapse_exception.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery::collapse - throws SolrMissingMandatoryParameterException
3 | --FILE--
4 | collapse($collapseFunction);
10 | } catch (SolrMissingMandatoryParameterException $e) {
11 | echo PHP_EOL.sprintf('Exception %d: %s', $e->getCode(), $e->getMessage());
12 | }
13 | ?>
14 | --EXPECTF--
15 | Exception 4100: Mandatory parameter Missing: field
16 |
--------------------------------------------------------------------------------
/tests/072.solrquery_expand.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery - Expand Component
3 | --FILE--
4 | setExpand(true);
9 | $query->setExpandRows(50);
10 | $query->setExpandQuery('text:product');
11 | $query->addExpandFilterQuery('manu:apple')->addExpandFilterQuery('inStock:true');
12 | $query->addExpandSortField('score', SolrQuery::ORDER_DESC)->addExpandSortField('title', SolrQuery::ORDER_ASC);
13 |
14 | // removal test
15 | $query->addExpandFilterQuery('extra')->removeExpandFilterQuery('extra');
16 | $query->addExpandSortField('extra', SolrQuery::ORDER_ASC)->removeExpandSortField('extra');
17 |
18 | echo $query.PHP_EOL;
19 | var_dump($query->getExpand()).PHP_EOL;
20 | var_dump($query->getExpandRows()).PHP_EOL;
21 | var_dump($query->getExpandQuery()).PHP_EOL;
22 | var_dump($query->getExpandFilterQueries()).PHP_EOL;
23 | var_dump($query->getExpandSortFields()).PHP_EOL;
24 | ?>
25 | --EXPECTF--
26 | q=lucene&expand=true&expand.rows=50&expand.q=text:product&expand.fq=manu:apple&expand.fq=inStock:true&expand.sort=score desc,title asc
27 | bool(true)
28 | int(50)
29 | string(12) "text:product"
30 | array(2) {
31 | [0]=>
32 | string(10) "manu:apple"
33 | [1]=>
34 | string(12) "inStock:true"
35 | }
36 | array(2) {
37 | [0]=>
38 | string(5) "score"
39 | [1]=>
40 | string(5) "title"
41 | }
42 |
--------------------------------------------------------------------------------
/tests/080.solrutils_escapequerychars.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrUtils::escapeQueryChars() - Testing Lucene Reserved Characters
3 | --FILE--
4 |
10 | --EXPECTF--
11 | \+a \- q\{ \} \[\^test\] \|| \&& \(\) \^ \" \~ \* \? \: \\ \/
--------------------------------------------------------------------------------
/tests/082.solrutils_getsolrversion.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrUtils::getSolrVersion() - Returns solr dotted version
3 | --FILE--
4 |
11 | --EXPECTF--
12 | %d.%d.%d
13 | %d.%d.%d
--------------------------------------------------------------------------------
/tests/083.solrutils_getsolrstats.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrUtils::getSolrStats() - Get Statistics about number of documents/clients..etc
3 | --FILE--
4 | SOLR_SERVER_HOSTNAME,
11 | 'login' => SOLR_SERVER_USERNAME,
12 | 'password' => SOLR_SERVER_PASSWORD,
13 | 'port' => SOLR_SERVER_PORT,
14 | 'path' => SOLR_SERVER_PATH
15 | );
16 |
17 | $client = new SolrClient ( $options );
18 |
19 | $solrDoc = new SolrInputDocument();
20 |
21 | $params = new SolrModifiableParams();
22 |
23 | var_dump(SolrUtils::getSolrStats());
24 |
25 | ?>
26 | --EXPECT--
27 | array(3) {
28 | ["document_count"]=>
29 | int(0)
30 | ["client_count"]=>
31 | int(0)
32 | ["params_count"]=>
33 | int(0)
34 | }
35 | array(3) {
36 | ["document_count"]=>
37 | int(1)
38 | ["client_count"]=>
39 | int(1)
40 | ["params_count"]=>
41 | int(1)
42 | }
43 |
--------------------------------------------------------------------------------
/tests/084.solrutils_queryphrase.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrUtils::queryPhrase() - Escapes a query phrase
3 | --FILE--
4 |
9 | --EXPECT--
10 | "Book Title\: Apache Solr Server"
11 |
--------------------------------------------------------------------------------
/tests/090.solrserverexception_xml.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrServerException (xml) - Throw Exception on solr server exception using xml response writer
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | // 'wt' => 'xml'
18 | );
19 |
20 | $client = new SolrClient ( $options );
21 | $query = new SolrQuery ( "lucene\\" );
22 | try {
23 | $response = $client->query ( $query );
24 | } catch ( SolrServerException $e ) {
25 | echo sprintf("code: %d", $e->getCode()).PHP_EOL;
26 | echo sprintf("message: %s", $e->getMessage()).PHP_EOL;
27 | print_r($e->getInternalInfo());
28 | }
29 |
30 | ?>
31 | --EXPECTF--
32 | code: %d
33 | message: %s
34 | Array
35 | (
36 | [sourceline] => %d
37 | [sourcefile] => %s
38 | [zif_name] => %s
39 | )
40 |
--------------------------------------------------------------------------------
/tests/091.solrserverexception_json.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrServerException (json) - Throw Exception on solr server exception using json response writer
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | 'wt' => 'json'
18 | );
19 |
20 | $client = new SolrClient ( $options );
21 | $query = new SolrQuery ( "lucene\\" );
22 | try {
23 | $response = $client->query ( $query );
24 | print_r ( $response );
25 | } catch ( SolrServerException $e ) {
26 | echo sprintf("code: %d", $e->getCode()).PHP_EOL;
27 | echo sprintf("message: %s", $e->getMessage()).PHP_EOL;
28 | }
29 |
30 | ?>
31 | --EXPECTF--
32 | code: %d
33 | message: %s
--------------------------------------------------------------------------------
/tests/092.solrserverexception_php.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrServerException (phps) - Throw Exception on solr server exception using phps response writer
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | 'wt' => 'phps'
18 | );
19 |
20 | $client = new SolrClient ( $options );
21 | $query = new SolrQuery ( "lucene\\" );
22 | try {
23 | $response = $client->query ( $query );
24 | print_r ( $response );
25 | } catch ( SolrServerException $e ) {
26 | echo sprintf("code: %d", $e->getCode()).PHP_EOL;
27 | echo sprintf("message: %s", $e->getMessage()).PHP_EOL;
28 | }
29 |
30 | ?>
31 | --EXPECTF--
32 | code: %d
33 | message: %s
--------------------------------------------------------------------------------
/tests/100.solrresponse_json.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getResponse - JSON response writer
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | 'wt' => 'json'
18 | );
19 |
20 | $client = new SolrClient ( $options );
21 | $query = new SolrQuery ( "lucene" );
22 |
23 | $response = $client->query ( $query );
24 |
25 | $x = $response->getResponse();
26 | var_dump($x instanceof SolrObject);
27 | ?>
28 | --EXPECTF--
29 | bool(true)
--------------------------------------------------------------------------------
/tests/101.solrresponse_parseMode.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse - ParseMode
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | 'wt' => 'xml'
18 | );
19 |
20 | $client = new SolrClient ( $options );
21 | $query = new SolrQuery ( "lucene" );
22 |
23 | $response = $client->query ( $query );
24 |
25 | $response->setParseMode(SolrResponse::PARSE_SOLR_DOC);
26 | $x = $response->getResponse();
27 | var_dump($x->response->docs[0] instanceof SolrDocument);
28 | ?>
29 | --EXPECTF--
30 | bool(true)
--------------------------------------------------------------------------------
/tests/102.solrresponse_phps.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getResponse - PHPS response writer
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | 'wt' => 'phps'
18 | );
19 |
20 | $client = new SolrClient ( $options );
21 | $query = new SolrQuery ( "lucene" );
22 |
23 | $response = $client->query ( $query );
24 |
25 | $x = $response->getResponse();
26 | var_dump($x instanceof SolrObject);
27 | ?>
28 | --EXPECTF--
29 | bool(true)
--------------------------------------------------------------------------------
/tests/103.solrresponse_get_array_response.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getArrayResponse - For All response writers
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | );
18 |
19 | $client = new SolrClient ( $options );
20 |
21 |
22 | $testArrayResponse = function ($writer) use ($client){
23 | $client->setResponseWriter($writer);
24 | $q = new SolrQuery("lucene");
25 | $response = $client->query ( $q );
26 | $arrayResponse = $response->getArrayResponse();
27 | return is_array($arrayResponse);
28 | };
29 |
30 | var_dump($testArrayResponse('phps'));
31 | var_dump($testArrayResponse('xml'));
32 | var_dump($testArrayResponse('json'));
33 | ?>
34 | --EXPECTF--
35 | bool(true)
36 | bool(true)
37 | bool(true)
--------------------------------------------------------------------------------
/tests/104.solrresponse_get_response_maxscore.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getResponse() - maxScore
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | 'wt'=> 'xml'
18 | );
19 |
20 | $client = new SolrClient ( $options );
21 |
22 | $q = new SolrQuery("lucene");
23 | $q->addField('score');
24 | $response = $client->query ( $q );
25 | $arrayResponse = $response->getArrayResponse();
26 | var_dump($arrayResponse['response']['maxScore']);
27 | var_dump($response->getResponse()->response->maxScore);
28 | var_dump($response->getResponse()->response->start);
29 | var_dump($response->getResponse()->response->numFound);
30 | var_dump(is_array($response->getResponse()->response->docs));
31 | echo "------ W/O maxScore ------".PHP_EOL;
32 | $q->removeField('score');
33 | $response = $client->query ( $q );
34 | var_dump($response->getResponse()->response->start);
35 | var_dump($response->getResponse()->response->numFound);
36 | var_dump(is_array($response->getResponse()->response->docs));
37 | var_dump(property_exists($response->getResponse()->response, 'maxScore'));
38 | ?>
39 | --EXPECTF--
40 | float(%f)
41 | float(%f)
42 | int(%d)
43 | int(%d)
44 | bool(true)
45 | ------ W/O maxScore ------
46 | int(0)
47 | int(1)
48 | bool(true)
49 | bool(false)
--------------------------------------------------------------------------------
/tests/105.solrresponse_child_doc_response.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Response - Response with child documents
3 | --FILE--
4 |
13 | --EXPECT--
14 | SolrObject Object
15 | (
16 | [response] => SolrObject Object
17 | (
18 | [numFound] => 3
19 | [start] => 0
20 | [docs] => Array
21 | (
22 | [0] => SolrObject Object
23 | (
24 | [id] => parent_1
25 | [_childDocuments_] => Array
26 | (
27 | [0] => SolrObject Object
28 | (
29 | [id] => CHILD_1_1
30 | )
31 |
32 | )
33 |
34 | )
35 |
36 | [1] => SolrObject Object
37 | (
38 | [id] => parent_2
39 | [_childDocuments_] => Array
40 | (
41 | [0] => SolrObject Object
42 | (
43 | [id] => CHILD_2_1
44 | )
45 |
46 | [1] => SolrObject Object
47 | (
48 | [id] => CHILD_2_2
49 | )
50 |
51 | )
52 |
53 | )
54 |
55 | [2] => SolrObject Object
56 | (
57 | [id] => not_a_parent_1
58 | )
59 |
60 | )
61 |
62 | )
63 |
64 | )
65 |
--------------------------------------------------------------------------------
/tests/107.solrresponse_getrawresponseheaders.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getRawResponseHeaders() - Get Raw Response Headers
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
15 | 'login' => SOLR_SERVER_USERNAME,
16 | 'password' => SOLR_SERVER_PASSWORD,
17 | 'port' => SOLR_SERVER_PORT,
18 | 'path' => SOLR_SERVER_PATH,
19 | );
20 |
21 |
22 | $client = new SolrClient($options);
23 |
24 | $query = new SolrQuery();
25 |
26 | $query->setQuery('lucene');
27 |
28 | $query->setStart(0);
29 |
30 | $query->setRows(50);
31 |
32 | $query->addField('cat')->addField('features')->addField('id')->addField('timestamp');
33 |
34 | $query_response = $client->query($query);
35 |
36 | $headers = $query_response->getRawResponseHeaders();
37 |
38 | $filteredHeaders = implode(
39 | "\n",
40 | array_filter(
41 | explode("\r\n", $headers),
42 | function($header) {
43 | return strpos($header, 'HTTP') === 0 || strpos($header, 'Content-Type') === 0;
44 | }
45 | )
46 | );
47 |
48 | print_r($filteredHeaders);
49 |
50 | ?>
51 | --EXPECTF--
52 | HTTP/%s 200 OK
53 | Content-Type: %s
54 |
--------------------------------------------------------------------------------
/tests/108.solrresponse_getdigestedresponse.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getDigestedResponse() - Get Raw Response Headers
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
15 | 'login' => SOLR_SERVER_USERNAME,
16 | 'password' => SOLR_SERVER_PASSWORD,
17 | 'port' => SOLR_SERVER_PORT,
18 | 'path' => SOLR_SERVER_PATH,
19 | );
20 |
21 |
22 | $client = new SolrClient($options);
23 |
24 | $query = new SolrQuery();
25 |
26 | $query->setQuery('lucene');
27 |
28 | $query->setStart(0);
29 |
30 | $query->setRows(50);
31 |
32 | $query->addField('cat')->addField('features')->addField('id')->addField('timestamp');
33 |
34 | $query_response = $client->query($query);
35 |
36 | var_dump($query_response->getDigestedResponse());
37 | $tmp = $query_response->getResponse();
38 | $digestedResponse = $query_response->getDigestedResponse();
39 | print_r($digestedResponse);
40 | ?>
41 | --EXPECTF--
42 | string(1) " "
43 | O:10:"SolrObject":2:{s:14:"responseHeader";O:10:"SolrObject":3:{s:6:"status";i:0;s:5:"QTime";i:%d;s:%d:"params";O:10:"SolrObject":7:{s:1:"q";s:6:"lucene";s:6:"indent";s:2:"on";s:2:"fl";s:25:"cat,features,id,timestamp";s:5:"start";s:1:"0";s:4:"rows";s:2:"50";s:7:"version";s:3:"2.2";s:2:"wt";s:3:"xml";}}s:8:"response";O:10:"SolrObject":3:{s:8:"numFound";i:1;s:5:"start";i:0;s:4:"docs";a:1:{i:0;O:10:"SolrObject":3:{s:2:"id";s:8:"SOLR1000";s:3:"cat";a:2:{i:0;s:8:"software";i:1;s:6:"search";}s:8:"features";a:7:{i:0;s:51:"Advanced Full-Text Search Capabilities using Lucene";i:1;s:37:"Optimized for High Volume Web Traffic";i:2;s:46:"Standards Based Open Interfaces - XML and HTTP";i:3;s:44:"Comprehensive HTML Administration Interfaces";i:4;s:64:"Scalability - Efficient Replication to other Solr Search Servers";i:5;s:56:"Flexible and Adaptable with XML configuration and Schema";i:6;s:62:"Good unicode support: héllo (hello with an accent over the e)";}}}}}
--------------------------------------------------------------------------------
/tests/109.solrresponse_gethttpstatus.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getHttpStatus() - getHttpStatusMessage()
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
15 | 'login' => SOLR_SERVER_USERNAME,
16 | 'password' => SOLR_SERVER_PASSWORD,
17 | 'port' => SOLR_SERVER_PORT,
18 | 'path' => SOLR_SERVER_PATH,
19 | );
20 |
21 |
22 | $client = new SolrClient($options);
23 |
24 | $query = new SolrQuery();
25 |
26 | $query->setQuery('lucene');
27 |
28 | $query->setStart(0);
29 |
30 | $query->setRows(50);
31 |
32 | $query->addField('cat')->addField('features')->addField('id')->addField('timestamp');
33 |
34 | $query_response = $client->query($query);
35 |
36 | var_dump($query_response->getHttpStatus());
37 | var_dump($query_response->getHttpStatusMessage());
38 | ?>
39 | --EXPECTF--
40 | int(200)
41 | string(1) " "
--------------------------------------------------------------------------------
/tests/109.solrresponse_getrequesturl.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::getRequestUrl() - Get Raw Response Headers
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
15 | 'login' => SOLR_SERVER_USERNAME,
16 | 'password' => SOLR_SERVER_PASSWORD,
17 | 'port' => SOLR_SERVER_PORT,
18 | 'path' => SOLR_SERVER_PATH,
19 | );
20 |
21 |
22 | $client = new SolrClient($options);
23 |
24 | $query = new SolrQuery();
25 |
26 | $query->setQuery('lucene');
27 |
28 | $query->setStart(0);
29 |
30 | $query->setRows(50);
31 |
32 | $query->addField('cat')->addField('features')->addField('id')->addField('timestamp');
33 |
34 | $query_response = $client->query($query);
35 |
36 | echo $query_response->getRequestUrl();
37 | ?>
38 | --EXPECTF--
39 | http://%s:%s/solr/collection1/select/?version=2.2&indent=on&wt=xml
--------------------------------------------------------------------------------
/tests/109.solrresponse_success.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrResponse::success() - Was the request successful
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
15 | 'login' => SOLR_SERVER_USERNAME,
16 | 'password' => SOLR_SERVER_PASSWORD,
17 | 'port' => SOLR_SERVER_PORT,
18 | 'path' => SOLR_SERVER_PATH,
19 | );
20 |
21 |
22 | $client = new SolrClient($options);
23 |
24 | $query = new SolrQuery();
25 |
26 | $query->setQuery('lucene');
27 |
28 | $query_response = $client->query($query);
29 |
30 | var_dump($query_response->success());
31 | ?>
32 | --EXPECTF--
33 | bool(true)
--------------------------------------------------------------------------------
/tests/111.solrdismaxquery_boostquery.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDisMaxQuery - Boost Query
3 | --FILE--
4 | addBoostQuery('cat', 'electronics', 5.1)
9 | ->addBoostQuery('cat', 'hard drive')
10 | ;
11 | // reverse
12 | echo $dismaxQuery.PHP_EOL;
13 | $dismaxQuery
14 | ->removeBoostQuery('cat');
15 | echo $dismaxQuery.PHP_EOL;
16 |
17 | $dismaxQuery->setBoostQuery('cat:electronics manu:local^2');
18 | echo $dismaxQuery.PHP_EOL;
19 | ?>
20 | --EXPECTF--
21 | q=lucene&defType=edismax&bq=cat:electronics^5.1 cat:hard drive
22 | q=lucene&defType=edismax&bq=cat:hard drive
23 |
24 | Notice: SolrDisMaxQuery::setBoostQuery(): Parameter bq value(s) was overwritten by this call in %s on line %d
25 | q=lucene&defType=edismax&bq=cat:electronics manu:local^2
26 |
--------------------------------------------------------------------------------
/tests/112.solrdismaxquery_query_parser.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDisMaxQuery - QueryParser Switch
3 | --FILE--
4 | useDisMaxQueryParser();
8 | echo $dismaxQuery.PHP_EOL;
9 | $dismaxQuery->useEDisMaxQueryParser();
10 | echo $dismaxQuery.PHP_EOL;
11 | ?>
12 | --EXPECTF--
13 | q=hard drive&defType=edismax
14 | q=hard drive&defType=dismax
15 | q=hard drive&defType=edismax
--------------------------------------------------------------------------------
/tests/113.solrdismaxquery_bigramfields.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDisMaxQuery - BigramFields and slop (addBigramPhraseField, removeBigramPhraseField, setBigramPhraseFields)
3 | --FILE--
4 | addBigramPhraseField('cat', 2, 5.1)
9 | ->addBigramPhraseField('feature', 4.5)
10 | ;
11 | echo $dismaxQuery.PHP_EOL;
12 | // reverse
13 | $dismaxQuery
14 | ->removeBigramPhraseField('cat');
15 | echo $dismaxQuery.PHP_EOL;
16 |
17 | $dismaxQuery->setBigramPhraseFields("cat~5.1^2 feature^4.5");
18 | echo $dismaxQuery.PHP_EOL;
19 |
20 | $dismaxQuery->setBigramPhraseSlop(2);
21 | echo $dismaxQuery.PHP_EOL;
22 | ?>
23 | --EXPECTF--
24 | q=lucene&defType=%s&pf2=cat~5.1^2 feature^4.5
25 | q=lucene&defType=%s&pf2=feature^4.5
26 |
27 | Notice: SolrDisMaxQuery::setBigramPhraseFields(): Parameter pf2 value(s) was overwritten by this call in %s on line %d
28 | q=lucene&defType=%s&pf2=cat~5.1^2 feature^4.5
29 | q=lucene&defType=%s&pf2=cat~5.1^2 feature^4.5&ps2=2
30 |
--------------------------------------------------------------------------------
/tests/114.solrdismaxquery_trigramfields.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDisMaxQuery - TrigramFields and slop (addTrigramPhraseField, removeTrigramPhraseField, setTrigramPhraseFields)
3 | --FILE--
4 | addTrigramPhraseField('cat', 2, 5.1)
9 | ->addTrigramPhraseField('feature', 4.5)
10 | ;
11 | echo $dismaxQuery.PHP_EOL;
12 | // reverse
13 | $dismaxQuery
14 | ->removeTrigramPhraseField('cat');
15 | echo $dismaxQuery.PHP_EOL;
16 |
17 | $dismaxQuery->setTrigramPhraseFields('cat~5.1^2 feature^4.5');
18 | echo $dismaxQuery.PHP_EOL;
19 |
20 | $dismaxQuery->setTrigramPhraseSlop(2);
21 | echo $dismaxQuery.PHP_EOL;
22 | ?>
23 | --EXPECTF--
24 | q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5
25 | q=lucene&defType=%s&pf3=feature^4.5
26 |
27 | Notice: SolrDisMaxQuery::setTrigramPhraseFields(): Parameter pf3 value(s) was overwritten by this call in %s on line %d
28 | q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5
29 | q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5&ps3=2
30 |
--------------------------------------------------------------------------------
/tests/115.solrdismaxquery_userfields.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDisMaxQuery - UserFields (uf parameter) (addUserField)
3 | --FILE--
4 | addUserField('cat')
8 | ->addUserField('text')
9 | ->addUserField('*_dt')
10 | ;
11 | echo $dismaxQuery.PHP_EOL;
12 | // // reverse
13 | $dismaxQuery
14 | ->removeUserField('text');
15 | echo $dismaxQuery.PHP_EOL;
16 |
17 | $dismaxQuery->setUserFields('field1 field2 *_txt');
18 | echo $dismaxQuery.PHP_EOL;
19 |
20 | ?>
21 | --EXPECTF--
22 | q=lucene&defType=%s&uf=cat text *_dt
23 | q=lucene&defType=%s&uf=cat *_dt
24 |
25 | Notice: SolrDisMaxQuery::setUserFields(): Parameter uf value(s) was overwritten by this call in %s on line %d
26 | q=lucene&defType=edismax&uf=field1 field2 *_txt
--------------------------------------------------------------------------------
/tests/116.solrdismaxquery_boostfunction.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDisMaxQuery - setBoostFunction
3 | --FILE--
4 | setBoostFunction($boostRecentDocsFunction);
10 |
11 | echo $dismaxQuery.PHP_EOL;
12 |
13 | ?>
14 | --EXPECTF--
15 | q=lucene&defType=%s&bf=recip(ms(NOW,mydatefield),3.16e-11,1,1)
--------------------------------------------------------------------------------
/tests/130.parameters_simple_list_separator.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | simple_list_parameter type - Use of default, non-default separator
3 | --FILE--
4 | addField("te")->addField("te2");
8 | echo $query.PHP_EOL;
9 |
10 | $dismaxQuery = new SolrDisMaxQuery();
11 | $dismaxQuery
12 | ->addUserField('cat')
13 | ->addUserField('text')
14 | ->addUserField('*_dt')
15 | ;
16 | echo $dismaxQuery.PHP_EOL;
17 |
18 | ?>
19 | --EXPECTF--
20 | fl=te,te2
21 | defType=edismax&uf=cat text *_dt
--------------------------------------------------------------------------------
/tests/150.solrcollapsefunction.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrCollapseFunction - string conversion
3 | --FILE--
4 | setField('field2');
9 | $func->setMax('max');
10 | $func->setMin('min');
11 | $func->setSize(1000);
12 | $func->setHint('hint');
13 | $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
14 |
15 | var_dump($func->getField());
16 | var_dump($func->getMax());
17 | var_dump($func->getMin());
18 | var_dump($func->getSize());
19 | var_dump($func->getHint());
20 | var_dump($func->getNullPolicy());
21 |
22 | var_dump((string)$func);
23 | $func->setMax('with space');
24 | var_dump((string)$func);
25 |
26 | ?>
27 | --EXPECTF--
28 | string(6) "field2"
29 | string(3) "max"
30 | string(3) "min"
31 | string(4) "1000"
32 | string(4) "hint"
33 | string(6) "expand"
34 | string(78) "{!collapse field=field2 max=max min=min size=1000 hint=hint nullPolicy=expand}"
35 | string(87) "{!collapse field=field2 max='with space' min=min size=1000 hint=hint nullPolicy=expand}"
36 |
--------------------------------------------------------------------------------
/tests/151.solrcollapsefunction_illegal_operations.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrCollapseFunction - Illegal Operations
3 | --SKIPIF--
4 |
5 | --FILE--
6 | getCode(), $e->getMessage()).PHP_EOL;
14 | }
15 |
16 | $func->setMax('max');
17 |
18 | try {
19 | // known issue, object corruption
20 | $tmp = serialize($func);
21 | } catch (SolrIllegalOperationException $e) {
22 | echo PHP_EOL . sprintf('Code %d: %s', $e->getCode(), $e->getMessage()).PHP_EOL;
23 | }
24 |
25 | ?>
26 | --EXPECTF--
27 | Code 4001: Cloning of SolrCollapseFunction objects is currently not supported
28 |
29 | Code 1001: Serialization of SolrCollapseFunction objects is currently not supported
30 |
31 |
--------------------------------------------------------------------------------
/tests/180.solrdocumentfield_construct.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocumentField::__construct
3 | --FILE--
4 |
11 | --EXPECT--
12 | SolrDocumentField Object
13 | (
14 | [name] =>
15 | [boost] => 0
16 | [values] =>
17 | )
18 |
--------------------------------------------------------------------------------
/tests/181.solrdocumentfield_write_property.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocumentField - exception - on write property
3 | --FILE--
4 | myIllegalProperty = 1;
11 | } catch (SolrIllegalOperationException $e) {
12 | printf("Exception %d: %s", $e->getCode(), $e->getMessage());
13 | }
14 |
15 | ?>
16 | --EXPECT--
17 | Exception 1007: SolrDocumentField instances are read-only. Properties cannot be updated or removed.
18 |
--------------------------------------------------------------------------------
/tests/182.solrdocumentfield_unset_property.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocumentField - exception - on unset property
3 | --FILE--
4 | name);
12 | } catch (SolrIllegalOperationException $e) {
13 | printf("Exception %d: %s", $e->getCode(), $e->getMessage());
14 | }
15 |
16 | ?>
17 | --EXPECT--
18 | Exception 1007: SolrDocumentField instances are read-only. Properties cannot be updated or removed.
--------------------------------------------------------------------------------
/tests/190.solrparams_setparam.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::setParam()
3 | --FILE--
4 | setParam('q', 'lucene')
10 | ->setParam('start', 0)
11 | ->setParam('rows', 10)
12 | ;
13 |
14 | echo $params;
15 | ?>
16 | --EXPECTF--
17 | q=lucene&start=0&rows=10
18 |
--------------------------------------------------------------------------------
/tests/191.solrparams_addparam.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::addParam()
3 | --FILE--
4 | addParam('fq', 'popularity:[10 TO *]')
10 | ->addParam('fq', 'section:0')
11 | ;
12 |
13 | echo $params;
14 | ?>
15 | --EXPECTF--
16 | fq=popularity:[10 TO *]&fq=section:0
17 |
--------------------------------------------------------------------------------
/tests/192.solrparams_getparam.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::getParam()
3 | --FILE--
4 | set('q', 'lucene')
10 | ->addParam('fq', 'popularity:[10 TO *]')
11 | ->addParam('fq', 'section:0')
12 | ;
13 |
14 | var_dump($params->get('fq'));
15 | var_dump($params->get('q'));
16 | ?>
17 | --EXPECT--
18 | array(2) {
19 | [0]=>
20 | string(20) "popularity:[10 TO *]"
21 | [1]=>
22 | string(9) "section:0"
23 | }
24 | string(6) "lucene"
--------------------------------------------------------------------------------
/tests/193.solrparams_getparams.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::getParams()
3 | --FILE--
4 | set('q', 'lucene')
10 | ->addParam('fq', 'popularity:[10 TO *]')
11 | ->addParam('fq', 'section:0')
12 | ;
13 |
14 | var_dump($params->getParams());
15 | ?>
16 | --EXPECT--
17 | array(2) {
18 | ["q"]=>
19 | array(1) {
20 | [0]=>
21 | string(6) "lucene"
22 | }
23 | ["fq"]=>
24 | array(2) {
25 | [0]=>
26 | string(20) "popularity:[10 TO *]"
27 | [1]=>
28 | string(9) "section:0"
29 | }
30 | }
--------------------------------------------------------------------------------
/tests/194.solrparams_getpreparedparams.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::getPreparedParams()
3 | --FILE--
4 | set('q', 'lucene')
10 | ->addParam('fq', 'popularity:[10 TO *]')
11 | ->addParam('fq', 'section:0')
12 | ;
13 |
14 | var_dump($params->getPreparedParams());
15 | ?>
16 | --EXPECT--
17 | array(2) {
18 | ["q"]=>
19 | string(8) "q=lucene"
20 | ["fq"]=>
21 | string(50) "fq=popularity%3A%5B10%20TO%20%2A%5D&fq=section%3A0"
22 | }
23 |
--------------------------------------------------------------------------------
/tests/195.solrparams_tostring.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::toString()
3 | --FILE--
4 | setParam('q', 'lucene')
10 | ->setParam('start', 0)
11 | ->setParam('rows', 10)
12 | ->addParam('fq', 'popularity:[10 TO *]')
13 | ->addParam('fq', 'section:0')
14 | ;
15 |
16 | echo $params->toString().PHP_EOL;
17 | echo $params->toString(true);
18 | ?>
19 | --EXPECTF--
20 | q=lucene&start=0&rows=10&fq=popularity:[10 TO *]&fq=section:0
21 | q=lucene&start=0&rows=10&fq=popularity%3A%5B10%20TO%20%2A%5D&fq=section%3A0
--------------------------------------------------------------------------------
/tests/196.solrparams_serialize.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::serialize() - serialize params
3 | --SKIPIF--
4 | = 80100) die("skip PHP < 8.1 only"); ?>
5 | --FILE--
6 | setParam('q', 'lucene')
12 | ->setParam('start', 0)
13 | ->setParam('rows', 10)
14 | ->addParam('fq', 'popularity:[10 TO *]')
15 | ->addParam('fq', 'section:0')
16 | ;
17 |
18 | echo serialize($params);
19 | ?>
20 | --EXPECTF--
21 | C:20:"SolrModifiableParams":727:{
22 |
23 |
24 |
25 | lucene
26 |
27 |
28 | 0
29 |
30 |
31 | 10
32 |
33 |
34 | popularity:[10 TO *]
35 | section:0
36 |
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/tests/196.solrparams_serialize_php81.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::serialize() - serialize params
3 | --SKIPIF--
4 |
5 | --FILE--
6 | setParam('q', 'lucene')
12 | ->setParam('start', 0)
13 | ->setParam('rows', 10)
14 | ->addParam('fq', 'popularity:[10 TO *]')
15 | ->addParam('fq', 'section:0')
16 | ;
17 |
18 | echo serialize($params);
19 | ?>
20 | --EXPECTF--
21 | O:20:"SolrModifiableParams":1:{s:3:"xml";s:727:"
22 |
23 |
24 |
25 | lucene
26 |
27 |
28 | 0
29 |
30 |
31 | 10
32 |
33 |
34 | popularity:[10 TO *]
35 | section:0
36 |
37 |
38 |
39 | ";}
40 |
--------------------------------------------------------------------------------
/tests/197.solrparams_unserialize.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams::unserialize()
3 | --FILE--
4 | setParam('q', 'lucene')
10 | ->setParam('start', 0)
11 | ->setParam('rows', 10)
12 | ->addParam('fq', 'popularity:[10 TO *]')
13 | ->addParam('fq', 'section:0')
14 | ;
15 |
16 | $serializedString = serialize($params);
17 |
18 | $unserializedObject = unserialize($serializedString);
19 | echo $unserializedObject;
20 | ?>
21 | --EXPECTF--
22 | q=lucene&start=0&rows=10&fq=popularity:[10 TO *]&fq=section:0
23 |
--------------------------------------------------------------------------------
/tests/198.solrparams_clone.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrParams - clone [exception]
3 | --FILE--
4 | setParam('q', 'lucene')
10 | ->setParam('start', 0)
11 | ->setParam('rows', 10)
12 | ->addParam('fq', 'popularity:[10 TO *]')
13 | ->addParam('fq', 'section:0')
14 | ;
15 |
16 | try {
17 | $params2 = clone $params;
18 | } catch (SolrIllegalOperationException $e) {
19 | echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()).PHP_EOL;
20 | }
21 |
22 | ?>
23 | --EXPECTF--
24 | Exception 4001: Cloning of SolrParams object instances is currently not supported
25 |
--------------------------------------------------------------------------------
/tests/200.solrextractrequest_clone.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrExtractRequest - clone [exception]
3 | --FILE--
4 | getCode(), $e->getMessage()).PHP_EOL;
14 | }
15 |
16 | ?>
17 | --EXPECTF--
18 | Exception 4001: Cloning of SolrExtractRequest objects is currently not supported
19 |
--------------------------------------------------------------------------------
/tests/201.solrextractrequest_serialize.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrExtractRequest - serialize [exception]
3 | --FILE--
4 | getCode(), $e->getMessage()).PHP_EOL;
14 | }
15 | ?>
16 | --EXPECTF--
17 | Exception 4001: SolrExtractRequest objects cannot be serialized or unserialized
18 |
--------------------------------------------------------------------------------
/tests/202.solrdocument_new_serialize.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrDocument - new serialize api
3 | --SKIPIF--
4 |
5 | --FILE--
6 | parent_2';
8 | $xml_length = strlen($xml_contents);
9 | $old = sprintf('C:12:"SolrDocument":%d:{%s}', $xml_length, $xml_contents);
10 | $new = sprintf('O:12:"SolrDocument":1:{s:3:"xml";s:%d:"%s";}', $xml_length, $xml_contents);
11 |
12 | /** @var SolrDocument $docOld */
13 | $docOld = unserialize($old);
14 | /** @var SolrDocument $docNew */
15 | $docNew = unserialize($new);
16 | var_dump(
17 | json_encode($docOld->toArray()) === json_encode($docNew->toArray())
18 | );
19 | var_dump($docNew->__serialize());
20 | ?>
21 | --EXPECT--
22 | bool(true)
23 | array(1) {
24 | ["xml"]=>
25 | string(172) "
26 |
27 |
28 |
29 | parent_2
30 |
31 |
32 |
33 | "
34 | }
35 |
--------------------------------------------------------------------------------
/tests/203.solrquery_strict_types.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrQuery - Strict type parameters without BC break
3 | --FILE--
4 | setStart(1);
9 | $query->setRows(2);
10 | $query->setTimeAllowed(300);
11 | $query->setGroupOffset(1);
12 | $query->setExpandRows(1);
13 |
14 | echo $query . "\n";
15 |
16 | // Now with strings
17 | $query = new SolrQuery('lucene');
18 | $query->setStart('1anystring'); // we don't do any checking
19 | $query->setRows('2');
20 | $query->setTimeAllowed('300');
21 | $query->setGroupOffset('1');
22 | $query->setExpandRows('1');
23 |
24 | echo $query . "\n";
25 |
26 | try { $query->setStart(true); } catch (SolrIllegalArgumentException $e) { echo $e->getMessage() . "\n"; }
27 |
28 | $collapse = new SolrCollapseFunction();
29 | $collapse->setSize(1);
30 |
31 | echo $collapse . "\n";
32 |
33 | $d = new SolrDisMaxQuery('lucene');
34 | $d->setPhraseSlop(2);
35 | $d->setQueryPhraseSlop(3);
36 | $d->setBigramPhraseSlop(4);
37 | $d->setTrigramPhraseSlop(5);
38 |
39 | echo $d . "\n";
40 |
41 | --EXPECT--
42 | q=lucene&start=1&rows=2&timeAllowed=300&group.offset=1&expand.rows=1
43 | q=lucene&start=1anystring&rows=2&timeAllowed=300&group.offset=1&expand.rows=1
44 | Argument 1 must be an int
45 | {!collapse size=1}
46 | q=lucene&defType=edismax&ps=2&qs=3&ps2=4&ps3=5
47 |
48 |
--------------------------------------------------------------------------------
/tests/204.solrutils_empty_escapequerychars.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | SolrUtils::escapeQueryChars() - Testing empty queryString
3 | --FILE--
4 |
8 | --EXPECTF--
9 | string(0) ""
10 | string(2) """"
11 |
--------------------------------------------------------------------------------
/tests/bootstrap.inc:
--------------------------------------------------------------------------------
1 | getCode(), $e->getMessage()). PHP_EOL;
11 | }
12 |
13 | /**
14 | * Prints a test case title
15 | *
16 | * @param int $case_id
17 | * @param string $title
18 | */
19 | function case_title(int $case_id, string $title) {
20 | $caseTemplate = PHP_EOL . "case #%d: %s" . PHP_EOL;
21 | echo sprintf($caseTemplate, $case_id, $title);
22 | }
23 |
--------------------------------------------------------------------------------
/tests/bug_59511_error.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr bug #59511 - SolrClient::query() Timeout shall throw a SolrClientException
3 | --SKIPIF--
4 |
5 | --FILE--
6 | 'anyhost',
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => SOLR_SERVER_PATH,
17 | 'timeout' => 2
18 | );
19 |
20 | $client = new SolrClient($options);
21 | $query = new SolrQuery("lucene");
22 | try {
23 | $query_response = $client->query($query);
24 | } catch (SolrClientException $e) {
25 | echo $e->getMessage().PHP_EOL;
26 | echo $e->getCode().PHP_EOL;
27 | }
28 | ?>
29 | --EXPECTF--
30 | Solr HTTP Error %d: '%s'
31 | 1004
--------------------------------------------------------------------------------
/tests/bug_61836_error.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr bug #61836 - Extending SolrDocument
3 | --SKIPIF--
4 |
5 | --FILE--
6 | addField('testname', true);
19 | ?>
20 | --EXPECTF--
21 | Fatal error: Class Model_SolrDocument %s final class %s
22 |
--------------------------------------------------------------------------------
/tests/bug_67394.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #67394 - Unable to parse response with NaN
3 | --FILE--
4 | stats->stats_fields->date->stddev);
13 |
14 | $xmlFixture = file_get_contents(ROOT_DIRECTORY . '/files/bug67394.xml');
15 | if (!json_decode($fixture)) {
16 | echo "PHP JSON DECODE failed with: ". json_last_error_msg().PHP_EOL;
17 | }
18 | $response = SolrUtils::digestXmlResponse($xmlFixture);
19 |
20 | var_dump($response->response->stats->stats_fields->currentPrice->mean);
21 | ?>
22 | --EXPECTF--
23 | string(3) "NaN"
24 | float(NAN)
--------------------------------------------------------------------------------
/tests/bug_68179.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #68179 - Solr Params (Argument list) separator disappears
3 | --FILE--
4 | addSortField('price', SolrQuery::ORDER_ASC);
7 | $dismaxQuery->addSortField('score', SolrQuery::ORDER_DESC);
8 | echo $dismaxQuery.PHP_EOL;
9 | ?>
10 | --EXPECTF--
11 | q=score&defType=%s&sort=price asc,score desc
--------------------------------------------------------------------------------
/tests/bug_68181.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #68181 - Conflict occurs when using SolrDisMax::addBoostQuery and setBoostQuery
3 | --FILE--
4 | setBoostQuery("failing:val^3")
7 | ->addBoostQuery('category','software',2)
8 | ->setBoostQuery("end:result^4");
9 |
10 | echo $dismaxQuery.PHP_EOL;
11 | ?>
12 | --EXPECTF--
13 | Notice: SolrDisMaxQuery::addBoostQuery(): Parameter bq value(s) was overwritten by this call in %s on line %d
14 |
15 | Notice: SolrDisMaxQuery::setBoostQuery(): Parameter bq value(s) was overwritten by this call in %s on line %d
16 | q=lucene&defType=%s&bq=end:result^4
--------------------------------------------------------------------------------
/tests/bug_69156.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #69156 - segfault on 500 response from Solr
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
13 | 'login' => SOLR_SERVER_USERNAME,
14 | 'password' => SOLR_SERVER_PASSWORD,
15 | 'port' => SOLR_SERVER_PORT,
16 | 'path' => 'solr/collection44444',
17 | 'wt' => 'phps'
18 | );
19 |
20 | $client = new SolrClient($options);
21 | $query = new SolrQuery("lucene");
22 | try {
23 | $query_response = $client->query($query);
24 | } catch (Exception $e) {
25 | }
26 | ?>
27 | --EXPECTF--
28 | Notice: SolrClient::query(): Unable to parse serialized php response in %s on line %d
29 |
--------------------------------------------------------------------------------
/tests/bug_70482.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #70482 - Segmentation fault on server 500 response with no msg field XML RW
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
12 | 'login' => SOLR_SERVER_USERNAME,
13 | 'password' => SOLR_SERVER_PASSWORD,
14 | 'port' => SOLR_SERVER_PORT,
15 | 'path' => SOLR_SERVER_PATH,
16 | 'wt' => 'xml'
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $query = new SolrQuery('*:*');
22 |
23 | $func = new SolrCollapseFunction('manu_id_s');
24 |
25 | $func->setMax('sum(cscore(),field(manu_id_s))');
26 | $func->setSize(100);
27 | $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
28 |
29 | $query->collapse($func);
30 | try {
31 | $queryResponse = $client->query($query);
32 | } catch (SolrServerException $e) {
33 | printf("Exception code %d", $e->getCode());
34 | assert(strlen($e->getMessage()) > 0, 'Exception message is empty');
35 | echo PHP_EOL;
36 | }
37 |
38 | ?>
39 | OK
40 | --EXPECTF--
41 | Exception code %d
42 | OK
--------------------------------------------------------------------------------
/tests/bug_70495.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #70495 - Failed to parse 500 error response when Solr it lacks msg JSON RW
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
12 | 'login' => SOLR_SERVER_USERNAME,
13 | 'password' => SOLR_SERVER_PASSWORD,
14 | 'port' => SOLR_SERVER_PORT,
15 | 'path' => SOLR_SERVER_PATH,
16 | 'wt' => 'json'
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $query = new SolrQuery('*:*');
22 |
23 | $func = new SolrCollapseFunction('manu_id_s');
24 |
25 | $func->setMax('sum(cscore(),field(manu_id_s))');
26 | $func->setSize(100);
27 | $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
28 |
29 | $query->collapse($func);
30 | try {
31 | $queryResponse = $client->query($query);
32 | } catch (SolrServerException $e) {
33 | printf("Exception code %d", $e->getCode());
34 | assert(strlen($e->getMessage()) > 0, 'Exception message is empty');
35 | }
36 |
37 | ?>
38 |
39 | OK
40 | --EXPECTF--
41 | Exception code 500
42 | OK
--------------------------------------------------------------------------------
/tests/bug_70496.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #70496 - Failed to parse 500 error response when Solr it lacks msg PHPS RW
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
12 | 'login' => SOLR_SERVER_USERNAME,
13 | 'password' => SOLR_SERVER_PASSWORD,
14 | 'port' => SOLR_SERVER_PORT,
15 | 'path' => SOLR_SERVER_PATH,
16 | 'wt' => 'phps'
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $query = new SolrQuery('*:*');
22 |
23 | $func = new SolrCollapseFunction('manu_id_s');
24 |
25 | $func->setMax('sum(cscore(),field(manu_id_s))');
26 | $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
27 |
28 | $query->collapse($func);
29 | try {
30 | $queryResponse = $client->query($query);
31 | } catch (SolrServerException $e) {
32 | printf("Exception code %d", $e->getCode());
33 | assert(strlen($e->getMessage()) > 0, 'Exception message is empty');
34 | }
35 |
36 | ?>
37 |
38 | OK
39 | --EXPECTF--
40 | Exception code 500
41 | OK
--------------------------------------------------------------------------------
/tests/bug_72033.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #72033 - Real Time Get requests fails if it wasn't the first request
3 | --SKIPIF--
4 |
7 | --FILE--
8 | SOLR_SERVER_HOSTNAME,
15 | 'login' => SOLR_SERVER_USERNAME,
16 | 'password' => SOLR_SERVER_PASSWORD,
17 | 'port' => SOLR_SERVER_PORT,
18 | 'path' => SOLR_SERVER_PATH
19 | );
20 |
21 | $client = new SolrClient($options);
22 |
23 | $doc = new SolrInputDocument();
24 |
25 | $doc->addField('id', 'some_id');
26 | $doc->addField('field1', 'val1');
27 |
28 | $client->addDocument($doc);
29 |
30 | $client->commit();
31 |
32 | $response = $client->getById('some_id');
33 |
34 | var_dump(isset($response->getArrayResponse()['doc'])).PHP_EOL;
35 | var_dump($response->getResponse()->doc->id) . PHP_EOL;
36 | // pointless request just to fill the request buffer
37 | $client->commit();
38 |
39 |
40 | $response = $client->getByIds(['GB18030TEST', '6H500F0']);
41 |
42 | var_dump($response->getResponse()->response->docs[0]->id, $response->getResponse()->response->docs[1]->id);
43 | ?>
44 | --EXPECTF--
45 | bool(true)
46 | string(7) "some_id"
47 | string(11) "GB18030TEST"
48 | string(7) "6H500F0"
49 |
--------------------------------------------------------------------------------
/tests/bug_unknown.phpt:
--------------------------------------------------------------------------------
1 | --TEST--
2 | Solr Bug #70496 - Failed to parse 500 error response when Solr it lacks msg PHPS RW
3 | --SKIPIF--
4 |
5 | --FILE--
6 | SOLR_SERVER_HOSTNAME,
12 | 'login' => SOLR_SERVER_USERNAME,
13 | 'password' => SOLR_SERVER_PASSWORD,
14 | 'port' => SOLR_SERVER_PORT,
15 | 'path' => SOLR_SERVER_PATH,
16 | 'wt' => 'phps'
17 | );
18 |
19 | $client = new SolrClient($options);
20 |
21 | $query = new SolrQuery('*:*');
22 |
23 | $func = new SolrCollapseFunction('manu_id_s');
24 |
25 | $func->setMax('sum(cscore(),field(manu_id_s))');
26 | $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
27 |
28 | $query->collapse($func);
29 | try {
30 | $queryResponse = $client->query($query);
31 | } catch (SolrServerException $e) {
32 | printf("Exception code %d", $e->getCode());
33 | assert(strlen($e->getMessage()) > 0, 'Exception message is empty');
34 | }
35 |
36 | ?>
37 |
38 | OK
39 | --EXPECTF--
40 | Exception code 500
41 | OK
--------------------------------------------------------------------------------
/tests/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM solr:6.3
2 |
3 | COPY collections collections
4 |
5 | RUN solr start &&\
6 | solr create -c collection1 &&\
7 | solr create -c metal_store &&\
8 | solr create -c myfiles &&\
9 | curl 'http://localhost:8983/solr/collection1/update/json?commit=true' --data-binary @collections/collection1.json -H 'Content-type:application/json' &&\
10 | curl 'http://localhost:8983/solr/metal_store/update/json?commit=true' --data-binary @collections/metal_store.json -H 'Content-type:application/json' &&\
11 | solr stop
12 |
--------------------------------------------------------------------------------
/tests/files/bug67394.json:
--------------------------------------------------------------------------------
1 | {
2 | "responseHeader": {
3 | "status": 0,
4 | "QTime": 5,
5 | "params": {
6 | "fl": "date",
7 | "indent": "true",
8 | "start": "0",
9 | "stats": "true",
10 | "stats.field": "date",
11 | "q": "bahruz",
12 | "_": "1402067668264",
13 | "wt": "json",
14 | "rows": "1"
15 | }
16 | },
17 | "response": {
18 | "numFound": 1039,
19 | "start": 0,
20 | "docs": [
21 | {
22 | "date": "2012-10-10T15:05:18Z"
23 | }
24 | ]
25 | },
26 | "stats": {
27 | "stats_fields": {
28 | "date": {
29 | "min": "2011-10-20T11:16:34Z",
30 | "max": "2014-06-04T13:41:45Z",
31 | "count": 1039,
32 | "missing": 0,
33 | "sum": "47085-11-30T17:59:27.999Z",
34 | "mean": "2013-06-03T17:17:43.684Z",
35 | "sumOfSquares": -234260129500201700000,
36 | "stddev": "NaN",
37 | "facets": {}
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/tests/files/bug67394.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0
5 | 72
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | 0
15 | 0.0
16 | 0.0
17 | NaN
18 | 0.0
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/tests/files/extract_file.1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php/pecl-search_engine-solr/9a8452d7ddc06f18f97752b34198d9b36499d29d/tests/files/extract_file.1.pdf
--------------------------------------------------------------------------------
/tests/files/response_xml.2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | parent_1
6 |
7 | CHILD_1_1
8 |
9 |
10 |
11 | parent_2
12 |
13 | CHILD_2_1
14 |
15 |
16 | CHILD_2_2
17 |
18 |
19 |
20 | not_a_parent_1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/tests/files/response_xml.3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | parent_1
6 |
7 | Solr adds block join support
8 |
9 |
10 | CHILD_1_1
11 |
12 | SolrCloud supports it too!
13 |
14 |
15 |
16 |
17 | parent_2
18 |
19 | CHILD_2_1
20 |
21 | Cool features
22 |
23 |
24 |
25 | CHILD_2_2
26 |
27 | Cool features
28 |
29 |
30 |
31 |
32 | parent_3
33 |
34 | CHILD_3_1
35 |
36 | Cool features
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/tests/files/response_xml.4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0
5 | 0
6 |
7 | *:*
8 | 0
9 | 2
10 | xml
11 |
12 |
13 |
14 |
15 | GB18030TEST
16 |
17 | Test with some GB18030 encoded characters
18 |
19 |
20 | No accents here
21 | 这是一个功能
22 | This is a feature (translated)
23 | 这份文件是很有光泽
24 | This document is very shiny (translated)
25 |
26 |
27 | 0.0
28 |
29 |
30 | true
31 |
32 | 1513324811722424320
33 |
34 |
35 | SP2514N
36 |
37 | Samsung SpinPoint P120 SP2514N - hard drive - 250 GB -
38 | ATA-133
39 |
40 |
41 | Samsung Electronics Co. Ltd.
42 |
43 | samsung
44 |
45 | electronics
46 | hard drive
47 |
48 |
49 | 7200RPM, 8MB cache, IDE Ultra ATA-133
50 | NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing
51 | (FDB) motor
52 |
53 |
54 | 92.0
55 |
56 |
57 | 6
58 |
59 |
60 | true
61 |
62 | 2006-02-13T15:26:37Z
63 |
64 | 35.0752,-97.032
65 |
66 | 1513324812366249984
67 |
68 |
69 |
--------------------------------------------------------------------------------
/tests/files/sample.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Welcome to Solr
4 |
5 |
6 |
7 | Here is some text
8 |
9 | distinct
words
10 | Here is some text in a div
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tests/files/sample_1.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php/pecl-search_engine-solr/9a8452d7ddc06f18f97752b34198d9b36499d29d/tests/files/sample_1.xlsx
--------------------------------------------------------------------------------
/tests/files/solr-word.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php/pecl-search_engine-solr/9a8452d7ddc06f18f97752b34198d9b36499d29d/tests/files/solr-word.pdf
--------------------------------------------------------------------------------
/tests/skip.if.server_not_configured.inc:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/tests/test.config.inc:
--------------------------------------------------------------------------------
1 |
59 |
--------------------------------------------------------------------------------
/travis/pecl/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, Michael Wallner .
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
--------------------------------------------------------------------------------
/travis/pecl/README.md:
--------------------------------------------------------------------------------
1 | # travis-pecl
2 |
3 | These few lines of code support building and testing PHP extensions on Travis-CI.
4 |
5 | ## Usage
6 |
7 | First, we'll add this repo to our extension as submodule:
8 |
9 | git submodule add -n travis-pecl https://github.com/m6w6/travis-pecl.git travis/pecl
10 | git submodule update --init
11 |
12 | Let's build a `.travis.yml`by example. We'll use a simple PHP script, e.g. `gen_travis_yml.php`,
13 | which will generate the configuration for us:
14 |
15 | #!/usr/bin/env php
16 | # file generated by gen_travis_yml.php, do not edit!
17 |
18 | # use the container infrastructure
19 | sudo: false
20 |
21 | # we want to build a C library
22 | language: c
23 |
24 | # use the system's PHP to run this script
25 | addons:
26 | apt:
27 | packages:
28 | - php5-cli
29 | - php-pear
30 |
31 | # now we'll specify the build matrix environment
32 | env:
33 | ["5.4", "5.5", "5.6"],
42 | # test debug and non-debug builds
43 | "enable_debug",
44 | # test threadsafe and non-threadsafe builds
45 | "enable_maintainer_zts",
46 | # test with ext/json enabled an disabled
47 | "enable_json",
48 | # always build with iconv support
49 | "with_iconv" => ["yes"],
50 | ]);
51 |
52 | # output the build matrix
53 | foreach ($env as $e) {
54 | printf(" - %s\n", %e);
55 | }
56 |
57 | ?>
58 |
59 | before_script:
60 | # build the matrix' PHP version
61 | - make -f travis/pecl/Makefile php
62 | # build the extension, the PECL variable expects the extension name
63 | # and optionally the soname and a specific version of the extension
64 | # separeated by double colon, e.g. PECL=myext:ext:1.7.5
65 | - make -f travis/pecl/Makefile ext PECL=myext
66 |
67 | script:
68 | # run the PHPT test suite
69 | - make -f travis/pecl/Makefile test
70 |
71 |
72 | That's it, more TBD.
73 |
--------------------------------------------------------------------------------
/travis/pecl/check-packagexml.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | \n", $argv[0]);
8 | exit(1);
9 | }
10 |
11 | require_once "PEAR/Config.php";
12 | require_once "PEAR/PackageFile.php";
13 |
14 | define("PACKAGE_XML", $argv[1]);
15 | define("PACKAGE_DIR", dirname(PACKAGE_XML));
16 |
17 | $factory = new PEAR_PackageFile(PEAR_Config::singleton());
18 | $pf = $factory->fromPackageFile($argv[1], PEAR_VALIDATE_NORMAL);
19 |
20 | if (PEAR::isError($pf)) {
21 | fprintf(STDERR, "ERROR: %s\n", $pf->getMessage());
22 | exit(1);
23 | }
24 |
25 | foreach ($pf->getValidationWarnings() as $warning) {
26 | fprintf(STDERR, "%s: %s\n", strtoupper($warning["level"]), $warning["message"]);
27 | }
28 |
29 | $exit = 0;
30 | foreach ($pf->getFilelist() as $file => $attr) {
31 | if (!file_exists(PACKAGE_DIR."/".$file)) {
32 | $exit++;
33 | fprintf(STDERR, "File '%s' with role '%s' not found in '%s'\n",
34 | $file, $attr["role"], PACKAGE_DIR);
35 | }
36 | }
37 |
38 | if ($exit) {
39 | fprintf(STDERR, "%3d failure(s)\n", $exit);
40 | exit(1);
41 | }
42 |
--------------------------------------------------------------------------------
/travis/pecl/cppcheck.suppressions:
--------------------------------------------------------------------------------
1 | *:*/Zend/*
2 | varFuncNullUB
3 | variableScope
4 |
--------------------------------------------------------------------------------
/travis/pecl/fetch-master.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if test -d php-master; then
4 | cd php-master
5 | git pull
6 | else
7 | git clone --depth 1 -b master https://github.com/php/php-src php-master
8 | cd php-master
9 | fi
10 |
11 | ./buildconf
12 |
--------------------------------------------------------------------------------
/travis/pecl/gen-matrix.php:
--------------------------------------------------------------------------------
1 | $values) {
5 | if (is_numeric($key) && is_string($values)) {
6 | $key = $values;
7 | $values = ["no","yes"];
8 | }
9 | if (empty($apc)) {
10 | // seed
11 | foreach ($values as $val) {
12 | $apc[] = "$key=$val";
13 | }
14 | } else {
15 | // combine
16 | $cpc = $apc;
17 | $apc = [];
18 | foreach ($values as $val) {
19 | foreach ($cpc as $e) {
20 | $apc[] = "$e $key=$val";
21 | }
22 | }
23 | }
24 | }
25 | return $apc;
26 | };
27 |
--------------------------------------------------------------------------------
/travis/pecl/php-version-url-dist.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | $r) {
28 | printf("%s\t%s\tcurl -sSL %s%s | tar xj\n", $v, $r, $mirror,
29 | $versions[$r]["source"][0]["filename"]);
30 | }
31 |
--------------------------------------------------------------------------------
/travis/pecl/php-version-url-qa.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | $r) {
28 | printf("%s\t%s\tcurl -sSL %s | tar xj\n", $v,
29 | $versions["releases"][$r]["version"],
30 | $versions["releases"][$r]["files"]["bz2"]["path"]);
31 | }
32 |
--------------------------------------------------------------------------------
/travis/pecl/php-version.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 |