[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] com =?UTF-8?Q?pecl/search=5Fengine/solr=3A=20Cleaning=20up=20tests=3A=20t?= =?UTF-8?Q?est
From:       Omar Shaban <omars () php ! net>
Date:       2015-11-29 17:43:46
Message-ID: php-mail-f44f4b622764a3ddf20263d0f535861b1973827844 () git ! php ! net
[Download RAW message or body]

Commit:    eff0dfcd5c417f70a51145ebfae441d52ee7f8c9
Author:    Omar Shaban <omars@php.net>         Sun, 29 Nov 2015 19:43:46 +0200
Parents:   366d74035aa12c97115269f63411e58c1654928f
Branches:  master

Link:       http://git.php.net/?p=pecl/search_engine/solr.git;a=commitdiff;h=eff0dfcd5c417f70a51145ebfae441d52ee7f8c9


Log:
Cleaning up tests

Changed paths:
  D  tests/024.solrdocument_addchilddocument.phpt
  A  tests/024.solrdocument_child_fetch.phpt
  D  tests/025.solrdocument_getchilddocuments.phpt
  A  tests/025.solrdocument_haschilddocuments.phpt
  A  tests/026.solrdocument_getchilddocscount.phpt
  D  tests/026.solrdocument_hasChildDocuments.phpt
  A  tests/027.solrdocument_getinputdocument_children.phpt
  D  tests/027.solrinputdocument_serialization.phpt
  D  tests/028.solrdocument_child_doc_response.phpt
  D  tests/029.solrdocument_child_fetch.phpt
  D  tests/030.solrdocument_child_doc_response_solrdoc.phpt
  D  tests/031.solrdocument_haschilddocuments.phpt
  D  tests/032.solrdocument_getchilddocscount.phpt
  D  tests/033.solrdocument_getinputdocument_children.phpt
  D  tests/034.solr_update_document_block.phpt
  A  tests/050.solrinputdocument_addchilddocument.phpt
  A  tests/051.solrinputdocument_getchilddocuments.phpt
  A  tests/052.solrinputdocument_haschilddocuments.phpt
  A  tests/053.solrinputdocument_serialization.phpt
  D  tests/104.solrresponse_get_response_maxScore.phpt
  A  tests/104.solrresponse_get_response_maxscore.phpt
  A  tests/105.solrresponse_child_doc_response.phpt
  A  tests/106.solrresponse_child_doc_response_solrdoc.phpt
  A  tests/160.solr_update_document_block.phpt


["diff_eff0dfcd5c417f70a51145ebfae441d52ee7f8c9.txt" (text/plain)]

diff --git a/tests/024.solrdocument_addchilddocument.phpt \
b/tests/024.solrdocument_addchilddocument.phpt deleted file mode 100644
index aacc398..0000000
--- a/tests/024.solrdocument_addchilddocument.phpt
+++ /dev/null
@@ -1,39 +0,0 @@
---TEST--
-SolrInputDocument::addChildDocument() - add child document
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$doc = new SolrInputDocument();
-
-$secondDoc = new SolrInputDocument();
-
-$doc->addField('id', 1123);
-$doc->addField('features', "PHP Client Side");
-$doc->addField('features', "Fast development cycles");
-$doc->cat   = 'Information Technology';
-
-$secondDoc->addField('cat', 'Lucene Search');
-$secondDoc->cat = 'Custom Search';
-
-$doc->addChildDocument($secondDoc);
-
-var_dump($doc->hasChildDocuments(), $secondDoc->hasChildDocuments());
-
-print_r($doc->getChildDocuments()[0]->getField('cat'));
-
-?>
---EXPECT--
-bool(true)
-bool(false)
-SolrDocumentField Object
-(
-    [name] => cat
-    [boost] => 0
-    [values] => Array
-        (
-            [0] => Lucene Search
-        )
-
-)
diff --git a/tests/024.solrdocument_child_fetch.phpt \
b/tests/024.solrdocument_child_fetch.phpt new file mode 100644
index 0000000..26a01fe
--- /dev/null
+++ b/tests/024.solrdocument_child_fetch.phpt
@@ -0,0 +1,52 @@
+--TEST--
+SolrClient::query() - Query child documents SolrObject (Integ)
+--SKIPIF--
+<?php
+include 'skip.if.server_not_configured.inc';
+?>
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$options = array (
+		'hostname' => SOLR_SERVER_HOSTNAME,
+		'login' => SOLR_SERVER_USERNAME,
+		'password' => SOLR_SERVER_PASSWORD,
+		'port' => SOLR_SERVER_PORT,
+		'path' => SOLR_SERVER_STORE_PATH,
+		'wt' => 'xml' 
+);
+
+$client = new SolrClient ( $options );
+
+$query = new SolrQuery ();
+
+$query->setQuery ( 'id:1 AND {!parent which=$parentFilter}' );
+$query->setParam ( 'parentFilter', 'content_type_s:product' );
+$query->addFilterQuery('{!parent which=$parentFilter}');
+
+$query->addField ( '*' );
+$query->addField ( '[child parentFilter=$parentFilter]' );
+
+$query->setStart ( 0 );
+
+$query->setRows ( 50 );
+$queryResponse = $client->query ( $query );
+
+$response = $queryResponse->getResponse ();
+echo "----XML----" . PHP_EOL;
+var_dump($response->response->docs[0]->_childDocuments_[0]->id);
+
+echo "----JSON----" . PHP_EOL;
+$options['wt'] = 'json';
+$client = new SolrClient ( $options );
+$queryResponse = $client->query($query);
+$response = $queryResponse->getResponse ();
+var_dump($response->response->docs[0]->_childDocuments_[0]->id);
+?>
+--EXPECT--
+----XML----
+string(9) "IMM-HOW-S"
+----JSON----
+string(9) "IMM-HOW-S"
\ No newline at end of file
diff --git a/tests/025.solrdocument_getchilddocuments.phpt \
b/tests/025.solrdocument_getchilddocuments.phpt deleted file mode 100644
index 780be52..0000000
--- a/tests/025.solrdocument_getchilddocuments.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-SolrInputDocument::getChildDocuments() - add child document
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$doc = new SolrInputDocument();
-
-$secondDoc = new SolrInputDocument();
-
-$doc->addField('id', 1123);
-$doc->addField('features', "PHP Client Side");
-$doc->addField('features', "Fast development cycles");
-$doc->cat   = 'Information Technology';
-
-$secondDoc->addField('cat', 'Lucene Search');
-$secondDoc->cat = 'Custom Search';
-
-$doc->addChildDocument($secondDoc);
-
-print_r($doc->getChildDocuments()[0]->getField('cat'));
-
-?>
---EXPECT--
-SolrDocumentField Object
-(
-    [name] => cat
-    [boost] => 0
-    [values] => Array
-        (
-            [0] => Lucene Search
-        )
-
-)
\ No newline at end of file
diff --git a/tests/025.solrdocument_haschilddocuments.phpt \
b/tests/025.solrdocument_haschilddocuments.phpt new file mode 100644
index 0000000..dedffb9
--- /dev/null
+++ b/tests/025.solrdocument_haschilddocuments.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SolrDocument::hasChildDocuments() - Method test
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
+
+$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
+var_dump($response->response->docs[0]->hasChildDocuments());
+?>
+--EXPECT--
+bool(true)
\ No newline at end of file
diff --git a/tests/026.solrdocument_getchilddocscount.phpt \
b/tests/026.solrdocument_getchilddocscount.phpt new file mode 100644
index 0000000..6f020ae
--- /dev/null
+++ b/tests/026.solrdocument_getchilddocscount.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SolrDocument::getChildDocumentsCount() - Method test
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
+
+$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
+var_dump($response->response->docs[0]->getChildDocumentsCount());
+?>
+--EXPECT--
+int(1)
\ No newline at end of file
diff --git a/tests/026.solrdocument_hasChildDocuments.phpt \
b/tests/026.solrdocument_hasChildDocuments.phpt deleted file mode 100644
index 9570fea..0000000
--- a/tests/026.solrdocument_hasChildDocuments.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-SolrInputDocument::getChildDocuments() - add child document
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$doc = new SolrInputDocument();
-
-$secondDoc = new SolrInputDocument();
-
-$doc->addField('id', 1123);
-$doc->addField('features', "PHP Client Side");
-$doc->addField('features', "Fast development cycles");
-$doc->cat   = 'Information Technology';
-
-$secondDoc->addField('cat', 'Lucene Search');
-$secondDoc->cat = 'Custom Search';
-
-$doc->addChildDocument($secondDoc);
-
-var_dump($doc->hasChildDocuments());
-var_dump($secondDoc->hasChildDocuments());
-?>
---EXPECT--
-bool(true)
-bool(false)
\ No newline at end of file
diff --git a/tests/027.solrdocument_getinputdocument_children.phpt \
b/tests/027.solrdocument_getinputdocument_children.phpt new file mode 100644
index 0000000..d807379
--- /dev/null
+++ b/tests/027.solrdocument_getinputdocument_children.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Solrdocument::getInputDocument() - Where document has child docs
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
+
+$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
+
+foreach($response->response->docs as $doc)
+{
+	$childrenOfTheInput = $doc->getInputDocument()->getChildDocuments();
+	
+	if ($childrenOfTheInput)
+	{
+		var_dump(get_class(current($childrenOfTheInput)));
+		var_dump(current($childrenOfTheInput)->toArray());
+	}
+}
+
+?>
+--EXPECT--
+string(17) "SolrInputDocument"
+array(3) {
+  ["document_boost"]=>
+  float(0)
+  ["field_count"]=>
+  int(1)
+  ["fields"]=>
+  array(1) {
+    [0]=>
+    object(SolrDocumentField)#9 (3) {
+      ["name"]=>
+      string(2) "id"
+      ["boost"]=>
+      float(0)
+      ["values"]=>
+      array(1) {
+        [0]=>
+        string(9) "CHILD_1_1"
+      }
+    }
+  }
+}
+string(17) "SolrInputDocument"
+array(3) {
+  ["document_boost"]=>
+  float(0)
+  ["field_count"]=>
+  int(1)
+  ["fields"]=>
+  array(1) {
+    [0]=>
+    object(SolrDocumentField)#10 (3) {
+      ["name"]=>
+      string(2) "id"
+      ["boost"]=>
+      float(0)
+      ["values"]=>
+      array(1) {
+        [0]=>
+        string(9) "CHILD_2_1"
+      }
+    }
+  }
+}
diff --git a/tests/027.solrinputdocument_serialization.phpt \
b/tests/027.solrinputdocument_serialization.phpt deleted file mode 100644
index 689b2f4..0000000
--- a/tests/027.solrinputdocument_serialization.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-SolrInputDocument - serialize/unserialize Exception
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$doc = new SolrInputDocument();
-
-try {
-serialize($doc);
-} catch (Exception $e) {
-echo $e->getMessage().PHP_EOL;
-}
-?>
---EXPECT--
-SolrInputDocument objects cannot be serialized or unserialized
\ No newline at end of file
diff --git a/tests/028.solrdocument_child_doc_response.phpt \
b/tests/028.solrdocument_child_doc_response.phpt deleted file mode 100644
index 08eb47b..0000000
--- a/tests/028.solrdocument_child_doc_response.phpt
+++ /dev/null
@@ -1,64 +0,0 @@
---TEST--
-SolrUtils::digestXmlResponse() - Response with child documents
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
-
-$response = SolrUtils::digestXmlResponse($fixtureXml);
-print_r($response);
-?>
---EXPECT--
-SolrObject Object
-(
-    [response] => SolrObject Object
-        (
-            [numFound] => 3
-            [start] => 0
-            [docs] => Array
-                (
-                    [0] => SolrObject Object
-                        (
-                            [id] => parent_1
-                            [_childDocuments_] => Array
-                                (
-                                    [0] => SolrObject Object
-                                        (
-                                            [id] => CHILD_1_1
-                                        )
-
-                                )
-
-                        )
-
-                    [1] => SolrObject Object
-                        (
-                            [id] => parent_2
-                            [_childDocuments_] => Array
-                                (
-                                    [0] => SolrObject Object
-                                        (
-                                            [id] => CHILD_2_1
-                                        )
-
-                                    [1] => SolrObject Object
-                                        (
-                                            [id] => CHILD_2_2
-                                        )
-
-                                )
-
-                        )
-
-                    [2] => SolrObject Object
-                        (
-                            [id] => not_a_parent_1
-                        )
-
-                )
-
-        )
-
-)
diff --git a/tests/029.solrdocument_child_fetch.phpt \
b/tests/029.solrdocument_child_fetch.phpt deleted file mode 100644
index 26a01fe..0000000
--- a/tests/029.solrdocument_child_fetch.phpt
+++ /dev/null
@@ -1,52 +0,0 @@
---TEST--
-SolrClient::query() - Query child documents SolrObject (Integ)
---SKIPIF--
-<?php
-include 'skip.if.server_not_configured.inc';
-?>
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$options = array (
-		'hostname' => SOLR_SERVER_HOSTNAME,
-		'login' => SOLR_SERVER_USERNAME,
-		'password' => SOLR_SERVER_PASSWORD,
-		'port' => SOLR_SERVER_PORT,
-		'path' => SOLR_SERVER_STORE_PATH,
-		'wt' => 'xml' 
-);
-
-$client = new SolrClient ( $options );
-
-$query = new SolrQuery ();
-
-$query->setQuery ( 'id:1 AND {!parent which=$parentFilter}' );
-$query->setParam ( 'parentFilter', 'content_type_s:product' );
-$query->addFilterQuery('{!parent which=$parentFilter}');
-
-$query->addField ( '*' );
-$query->addField ( '[child parentFilter=$parentFilter]' );
-
-$query->setStart ( 0 );
-
-$query->setRows ( 50 );
-$queryResponse = $client->query ( $query );
-
-$response = $queryResponse->getResponse ();
-echo "----XML----" . PHP_EOL;
-var_dump($response->response->docs[0]->_childDocuments_[0]->id);
-
-echo "----JSON----" . PHP_EOL;
-$options['wt'] = 'json';
-$client = new SolrClient ( $options );
-$queryResponse = $client->query($query);
-$response = $queryResponse->getResponse ();
-var_dump($response->response->docs[0]->_childDocuments_[0]->id);
-?>
---EXPECT--
-----XML----
-string(9) "IMM-HOW-S"
-----JSON----
-string(9) "IMM-HOW-S"
\ No newline at end of file
diff --git a/tests/030.solrdocument_child_doc_response_solrdoc.phpt \
b/tests/030.solrdocument_child_doc_response_solrdoc.phpt deleted file mode 100644
index 7975c06..0000000
--- a/tests/030.solrdocument_child_doc_response_solrdoc.phpt
+++ /dev/null
@@ -1,152 +0,0 @@
---TEST--
-SolrDocument - Response with child documents (integ)
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
-
-$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
-
-foreach($response->response->docs as $doc)
-{
-	echo '--- doc start ---'.PHP_EOL;
-	print_r($doc->toArray());
-	if ($doc->hasChildDocuments())
-	{
-		foreach ($doc->getChildDocuments() as $child)
-		{
-			print_r($child->toArray());
-		}	
-	}
-	echo '--- doc end ---'.PHP_EOL;
-}
-?>
---EXPECT--
---- doc start ---
-Array
-(
-    [document_boost] => 0
-    [field_count] => 1
-    [fields] => Array
-        (
-            [0] => SolrDocumentField Object
-                (
-                    [name] => id
-                    [boost] => 0
-                    [values] => Array
-                        (
-                            [0] => parent_1
-                        )
-
-                )
-
-        )
-
-)
-Array
-(
-    [document_boost] => 0
-    [field_count] => 1
-    [fields] => Array
-        (
-            [0] => SolrDocumentField Object
-                (
-                    [name] => id
-                    [boost] => 0
-                    [values] => Array
-                        (
-                            [0] => CHILD_1_1
-                        )
-
-                )
-
-        )
-
-)
---- doc end ---
---- doc start ---
-Array
-(
-    [document_boost] => 0
-    [field_count] => 1
-    [fields] => Array
-        (
-            [0] => SolrDocumentField Object
-                (
-                    [name] => id
-                    [boost] => 0
-                    [values] => Array
-                        (
-                            [0] => parent_2
-                        )
-
-                )
-
-        )
-
-)
-Array
-(
-    [document_boost] => 0
-    [field_count] => 1
-    [fields] => Array
-        (
-            [0] => SolrDocumentField Object
-                (
-                    [name] => id
-                    [boost] => 0
-                    [values] => Array
-                        (
-                            [0] => CHILD_2_1
-                        )
-
-                )
-
-        )
-
-)
-Array
-(
-    [document_boost] => 0
-    [field_count] => 1
-    [fields] => Array
-        (
-            [0] => SolrDocumentField Object
-                (
-                    [name] => id
-                    [boost] => 0
-                    [values] => Array
-                        (
-                            [0] => CHILD_2_2
-                        )
-
-                )
-
-        )
-
-)
---- doc end ---
---- doc start ---
-Array
-(
-    [document_boost] => 0
-    [field_count] => 1
-    [fields] => Array
-        (
-            [0] => SolrDocumentField Object
-                (
-                    [name] => id
-                    [boost] => 0
-                    [values] => Array
-                        (
-                            [0] => not_a_parent_1
-                        )
-
-                )
-
-        )
-
-)
---- doc end ---
diff --git a/tests/031.solrdocument_haschilddocuments.phpt \
b/tests/031.solrdocument_haschilddocuments.phpt deleted file mode 100644
index dedffb9..0000000
--- a/tests/031.solrdocument_haschilddocuments.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SolrDocument::hasChildDocuments() - Method test
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
-
-$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
-var_dump($response->response->docs[0]->hasChildDocuments());
-?>
---EXPECT--
-bool(true)
\ No newline at end of file
diff --git a/tests/032.solrdocument_getchilddocscount.phpt \
b/tests/032.solrdocument_getchilddocscount.phpt deleted file mode 100644
index 6f020ae..0000000
--- a/tests/032.solrdocument_getchilddocscount.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SolrDocument::getChildDocumentsCount() - Method test
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
-
-$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
-var_dump($response->response->docs[0]->getChildDocumentsCount());
-?>
---EXPECT--
-int(1)
\ No newline at end of file
diff --git a/tests/033.solrdocument_getinputdocument_children.phpt \
b/tests/033.solrdocument_getinputdocument_children.phpt deleted file mode 100644
index d807379..0000000
--- a/tests/033.solrdocument_getinputdocument_children.phpt
+++ /dev/null
@@ -1,68 +0,0 @@
---TEST--
-Solrdocument::getInputDocument() - Where document has child docs
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
-
-$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
-
-foreach($response->response->docs as $doc)
-{
-	$childrenOfTheInput = $doc->getInputDocument()->getChildDocuments();
-	
-	if ($childrenOfTheInput)
-	{
-		var_dump(get_class(current($childrenOfTheInput)));
-		var_dump(current($childrenOfTheInput)->toArray());
-	}
-}
-
-?>
---EXPECT--
-string(17) "SolrInputDocument"
-array(3) {
-  ["document_boost"]=>
-  float(0)
-  ["field_count"]=>
-  int(1)
-  ["fields"]=>
-  array(1) {
-    [0]=>
-    object(SolrDocumentField)#9 (3) {
-      ["name"]=>
-      string(2) "id"
-      ["boost"]=>
-      float(0)
-      ["values"]=>
-      array(1) {
-        [0]=>
-        string(9) "CHILD_1_1"
-      }
-    }
-  }
-}
-string(17) "SolrInputDocument"
-array(3) {
-  ["document_boost"]=>
-  float(0)
-  ["field_count"]=>
-  int(1)
-  ["fields"]=>
-  array(1) {
-    [0]=>
-    object(SolrDocumentField)#10 (3) {
-      ["name"]=>
-      string(2) "id"
-      ["boost"]=>
-      float(0)
-      ["values"]=>
-      array(1) {
-        [0]=>
-        string(9) "CHILD_2_1"
-      }
-    }
-  }
-}
diff --git a/tests/034.solr_update_document_block.phpt \
b/tests/034.solr_update_document_block.phpt deleted file mode 100644
index 0caa934..0000000
--- a/tests/034.solr_update_document_block.phpt
+++ /dev/null
@@ -1,82 +0,0 @@
---TEST--
-SolrResponse - Fetch and Update nested documents
---SKIPIF--
-<?php
-include 'skip.if.server_not_configured.inc';
-?>
---FILE--
-<?php
-
-require_once "bootstrap.inc";
-
-$updateInventory = function ($document, $inventory) {
-	$children = $document->getChildDocuments();
-	$child = $children[0];
-	$child->deleteField('inventory_i');
-	$child->addField('inventory_i', $inventory);
-
-	$document->deleteField('_version_');
-};
-
-$getInventory = function ($response) {
-	return (int) current($response->response->docs[0]->getChildDocuments()[0]['inventory_i']->values);
                
-};
-
-$options = array (
-		'hostname' => SOLR_SERVER_HOSTNAME,
-		'login' => SOLR_SERVER_USERNAME,
-		'password' => SOLR_SERVER_PASSWORD,
-		'port' => SOLR_SERVER_PORT,
-		'path' => SOLR_SERVER_STORE_PATH,
-		'wt' => 'xml' 
-);
-
-$client = new SolrClient ( $options );
-
-$query = new SolrQuery ('id:1 AND {!parent which=$parentFilter}');
-
-$query->setParam ( 'parentFilter', 'content_type_s:product' );
-$query->addFilterQuery('{!parent which=$parentFilter}');
-
-$query->addField ( '*' );
-$query->addField ( '[child parentFilter=$parentFilter]' );
-
-$query->setStart ( 0 );
-$query->setRows ( 1 );
-
-// query existing inventory
-$queryResponse = $client->query ( $query );
-$queryResponse->setParseMode(SolrResponse::PARSE_SOLR_DOC);
-$response = $queryResponse->getResponse();
-$existingInventory = $getInventory($response);
-
-// update inventory to 300
-$document = $response->response->docs[0]->getInputDocument();
-$updateInventory($document, 300);
-$client->addDocument($document);
-$client->commit();
-
-// fetch the document again after the update
-$queryResponse = $client->query ( $query );
-$queryResponse->setParseMode(SolrResponse::PARSE_SOLR_DOC);
-$response = $queryResponse->getResponse();
-$newInventory = $getInventory($response);
-assert($newInventory == 300);
-
-
-echo "------EXISTING------" . PHP_EOL;
-var_dump($existingInventory);
-echo "----AFTER UPDATE----" . PHP_EOL;
-var_dump($newInventory);
-
-// cleanup: restore document's original state
-$document = $response->response->docs[0]->getInputDocument();
-$updateInventory($document, $existingInventory);
-$client->addDocument($document);
-$client->commit();
-?>
---EXPECT--
-------EXISTING------
-int(200)
-----AFTER UPDATE----
-int(300)
\ No newline at end of file
diff --git a/tests/050.solrinputdocument_addchilddocument.phpt \
b/tests/050.solrinputdocument_addchilddocument.phpt new file mode 100644
index 0000000..aacc398
--- /dev/null
+++ b/tests/050.solrinputdocument_addchilddocument.phpt
@@ -0,0 +1,39 @@
+--TEST--
+SolrInputDocument::addChildDocument() - add child document
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$doc = new SolrInputDocument();
+
+$secondDoc = new SolrInputDocument();
+
+$doc->addField('id', 1123);
+$doc->addField('features', "PHP Client Side");
+$doc->addField('features', "Fast development cycles");
+$doc->cat   = 'Information Technology';
+
+$secondDoc->addField('cat', 'Lucene Search');
+$secondDoc->cat = 'Custom Search';
+
+$doc->addChildDocument($secondDoc);
+
+var_dump($doc->hasChildDocuments(), $secondDoc->hasChildDocuments());
+
+print_r($doc->getChildDocuments()[0]->getField('cat'));
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
+SolrDocumentField Object
+(
+    [name] => cat
+    [boost] => 0
+    [values] => Array
+        (
+            [0] => Lucene Search
+        )
+
+)
diff --git a/tests/051.solrinputdocument_getchilddocuments.phpt \
b/tests/051.solrinputdocument_getchilddocuments.phpt new file mode 100644
index 0000000..d9c4b84
--- /dev/null
+++ b/tests/051.solrinputdocument_getchilddocuments.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SolrInputDocument::getChildDocuments() - test
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$doc = new SolrInputDocument();
+
+$secondDoc = new SolrInputDocument();
+
+$doc->addField('id', 1123);
+$doc->addField('features', "PHP Client Side");
+$doc->addField('features', "Fast development cycles");
+$doc->cat   = 'Information Technology';
+
+$secondDoc->addField('cat', 'Lucene Search');
+$secondDoc->cat = 'Custom Search';
+
+$doc->addChildDocument($secondDoc);
+
+print_r($doc->getChildDocuments()[0]->getField('cat'));
+
+?>
+--EXPECT--
+SolrDocumentField Object
+(
+    [name] => cat
+    [boost] => 0
+    [values] => Array
+        (
+            [0] => Lucene Search
+        )
+
+)
\ No newline at end of file
diff --git a/tests/052.solrinputdocument_haschilddocuments.phpt \
b/tests/052.solrinputdocument_haschilddocuments.phpt new file mode 100644
index 0000000..d5ef223
--- /dev/null
+++ b/tests/052.solrinputdocument_haschilddocuments.phpt
@@ -0,0 +1,27 @@
+--TEST--
+SolrInputDocument::hasChildDocuments() - test
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$doc = new SolrInputDocument();
+
+$secondDoc = new SolrInputDocument();
+
+$doc->addField('id', 1123);
+$doc->addField('features', "PHP Client Side");
+$doc->addField('features', "Fast development cycles");
+$doc->cat   = 'Information Technology';
+
+$secondDoc->addField('cat', 'Lucene Search');
+$secondDoc->cat = 'Custom Search';
+
+$doc->addChildDocument($secondDoc);
+
+var_dump($doc->hasChildDocuments());
+var_dump($secondDoc->hasChildDocuments());
+?>
+--EXPECT--
+bool(true)
+bool(false)
\ No newline at end of file
diff --git a/tests/053.solrinputdocument_serialization.phpt \
b/tests/053.solrinputdocument_serialization.phpt new file mode 100644
index 0000000..689b2f4
--- /dev/null
+++ b/tests/053.solrinputdocument_serialization.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SolrInputDocument - serialize/unserialize Exception
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$doc = new SolrInputDocument();
+
+try {
+serialize($doc);
+} catch (Exception $e) {
+echo $e->getMessage().PHP_EOL;
+}
+?>
+--EXPECT--
+SolrInputDocument objects cannot be serialized or unserialized
\ No newline at end of file
diff --git a/tests/104.solrresponse_get_response_maxScore.phpt \
b/tests/104.solrresponse_get_response_maxScore.phpt deleted file mode 100644
index b43be37..0000000
--- a/tests/104.solrresponse_get_response_maxScore.phpt
+++ /dev/null
@@ -1,49 +0,0 @@
---TEST--
-SolrResponse::getResponse() - maxScore
---SKIPIF--
-<?php
-include 'skip.if.server_not_configured.inc';
-?>
---FILE--
-<?php
-require_once "bootstrap.inc";
-
-$options = array (
-		'hostname' => SOLR_SERVER_HOSTNAME,
-		'login' => SOLR_SERVER_USERNAME,
-		'password' => SOLR_SERVER_PASSWORD,
-		'port' => SOLR_SERVER_PORT,
-		'path' => SOLR_SERVER_PATH,
-		'wt'=> 'xml'
-);
-
-$client = new SolrClient ( $options );
-
-$q = new SolrQuery("lucene");
-$q->addField('score');
-$response = $client->query ( $q );
-$arrayResponse = $response->getArrayResponse();
-var_dump($arrayResponse['response']['maxScore']);
-var_dump($response->getResponse()->response->maxScore);
-var_dump($response->getResponse()->response->start);
-var_dump($response->getResponse()->response->numFound);
-var_dump(is_array($response->getResponse()->response->docs));
-echo "------ W/O maxScore ------".PHP_EOL;
-$q->removeField('score');
-$response = $client->query ( $q );
-var_dump($response->getResponse()->response->start);
-var_dump($response->getResponse()->response->numFound);
-var_dump(is_array($response->getResponse()->response->docs));
-var_dump(property_exists($response->getResponse()->response, 'maxScore'));
-?>
---EXPECTF--
-float(%f)
-float(%f)
-int(%d)
-int(%d)
-bool(true)
------- W/O maxScore ------
-int(0)
-int(1)
-bool(true)
-bool(false)
\ No newline at end of file
diff --git a/tests/104.solrresponse_get_response_maxscore.phpt \
b/tests/104.solrresponse_get_response_maxscore.phpt new file mode 100644
index 0000000..b43be37
--- /dev/null
+++ b/tests/104.solrresponse_get_response_maxscore.phpt
@@ -0,0 +1,49 @@
+--TEST--
+SolrResponse::getResponse() - maxScore
+--SKIPIF--
+<?php
+include 'skip.if.server_not_configured.inc';
+?>
+--FILE--
+<?php
+require_once "bootstrap.inc";
+
+$options = array (
+		'hostname' => SOLR_SERVER_HOSTNAME,
+		'login' => SOLR_SERVER_USERNAME,
+		'password' => SOLR_SERVER_PASSWORD,
+		'port' => SOLR_SERVER_PORT,
+		'path' => SOLR_SERVER_PATH,
+		'wt'=> 'xml'
+);
+
+$client = new SolrClient ( $options );
+
+$q = new SolrQuery("lucene");
+$q->addField('score');
+$response = $client->query ( $q );
+$arrayResponse = $response->getArrayResponse();
+var_dump($arrayResponse['response']['maxScore']);
+var_dump($response->getResponse()->response->maxScore);
+var_dump($response->getResponse()->response->start);
+var_dump($response->getResponse()->response->numFound);
+var_dump(is_array($response->getResponse()->response->docs));
+echo "------ W/O maxScore ------".PHP_EOL;
+$q->removeField('score');
+$response = $client->query ( $q );
+var_dump($response->getResponse()->response->start);
+var_dump($response->getResponse()->response->numFound);
+var_dump(is_array($response->getResponse()->response->docs));
+var_dump(property_exists($response->getResponse()->response, 'maxScore'));
+?>
+--EXPECTF--
+float(%f)
+float(%f)
+int(%d)
+int(%d)
+bool(true)
+------ W/O maxScore ------
+int(0)
+int(1)
+bool(true)
+bool(false)
\ No newline at end of file
diff --git a/tests/105.solrresponse_child_doc_response.phpt \
b/tests/105.solrresponse_child_doc_response.phpt new file mode 100644
index 0000000..741a0f1
--- /dev/null
+++ b/tests/105.solrresponse_child_doc_response.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Response - Response with child documents
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
+
+$response = SolrUtils::digestXmlResponse($fixtureXml);
+print_r($response);
+?>
+--EXPECT--
+SolrObject Object
+(
+    [response] => SolrObject Object
+        (
+            [numFound] => 3
+            [start] => 0
+            [docs] => Array
+                (
+                    [0] => SolrObject Object
+                        (
+                            [id] => parent_1
+                            [_childDocuments_] => Array
+                                (
+                                    [0] => SolrObject Object
+                                        (
+                                            [id] => CHILD_1_1
+                                        )
+
+                                )
+
+                        )
+
+                    [1] => SolrObject Object
+                        (
+                            [id] => parent_2
+                            [_childDocuments_] => Array
+                                (
+                                    [0] => SolrObject Object
+                                        (
+                                            [id] => CHILD_2_1
+                                        )
+
+                                    [1] => SolrObject Object
+                                        (
+                                            [id] => CHILD_2_2
+                                        )
+
+                                )
+
+                        )
+
+                    [2] => SolrObject Object
+                        (
+                            [id] => not_a_parent_1
+                        )
+
+                )
+
+        )
+
+)
diff --git a/tests/106.solrresponse_child_doc_response_solrdoc.phpt \
b/tests/106.solrresponse_child_doc_response_solrdoc.phpt new file mode 100644
index 0000000..cec2aac
--- /dev/null
+++ b/tests/106.solrresponse_child_doc_response_solrdoc.phpt
@@ -0,0 +1,152 @@
+--TEST--
+SolrDocument - Response parsed as SolrDocument with child documents
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
+
+$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
+
+foreach($response->response->docs as $doc)
+{
+	echo '--- doc start ---'.PHP_EOL;
+	print_r($doc->toArray());
+	if ($doc->hasChildDocuments())
+	{
+		foreach ($doc->getChildDocuments() as $child)
+		{
+			print_r($child->toArray());
+		}	
+	}
+	echo '--- doc end ---'.PHP_EOL;
+}
+?>
+--EXPECT--
+--- doc start ---
+Array
+(
+    [document_boost] => 0
+    [field_count] => 1
+    [fields] => Array
+        (
+            [0] => SolrDocumentField Object
+                (
+                    [name] => id
+                    [boost] => 0
+                    [values] => Array
+                        (
+                            [0] => parent_1
+                        )
+
+                )
+
+        )
+
+)
+Array
+(
+    [document_boost] => 0
+    [field_count] => 1
+    [fields] => Array
+        (
+            [0] => SolrDocumentField Object
+                (
+                    [name] => id
+                    [boost] => 0
+                    [values] => Array
+                        (
+                            [0] => CHILD_1_1
+                        )
+
+                )
+
+        )
+
+)
+--- doc end ---
+--- doc start ---
+Array
+(
+    [document_boost] => 0
+    [field_count] => 1
+    [fields] => Array
+        (
+            [0] => SolrDocumentField Object
+                (
+                    [name] => id
+                    [boost] => 0
+                    [values] => Array
+                        (
+                            [0] => parent_2
+                        )
+
+                )
+
+        )
+
+)
+Array
+(
+    [document_boost] => 0
+    [field_count] => 1
+    [fields] => Array
+        (
+            [0] => SolrDocumentField Object
+                (
+                    [name] => id
+                    [boost] => 0
+                    [values] => Array
+                        (
+                            [0] => CHILD_2_1
+                        )
+
+                )
+
+        )
+
+)
+Array
+(
+    [document_boost] => 0
+    [field_count] => 1
+    [fields] => Array
+        (
+            [0] => SolrDocumentField Object
+                (
+                    [name] => id
+                    [boost] => 0
+                    [values] => Array
+                        (
+                            [0] => CHILD_2_2
+                        )
+
+                )
+
+        )
+
+)
+--- doc end ---
+--- doc start ---
+Array
+(
+    [document_boost] => 0
+    [field_count] => 1
+    [fields] => Array
+        (
+            [0] => SolrDocumentField Object
+                (
+                    [name] => id
+                    [boost] => 0
+                    [values] => Array
+                        (
+                            [0] => not_a_parent_1
+                        )
+
+                )
+
+        )
+
+)
+--- doc end ---
diff --git a/tests/160.solr_update_document_block.phpt \
b/tests/160.solr_update_document_block.phpt new file mode 100644
index 0000000..35e5f95
--- /dev/null
+++ b/tests/160.solr_update_document_block.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Solr - Fetch and Update nested documents
+--SKIPIF--
+<?php
+include 'skip.if.server_not_configured.inc';
+?>
+--FILE--
+<?php
+
+require_once "bootstrap.inc";
+
+$updateInventory = function ($document, $inventory) {
+	$children = $document->getChildDocuments();
+	$child = $children[0];
+	$child->deleteField('inventory_i');
+	$child->addField('inventory_i', $inventory);
+
+	$document->deleteField('_version_');
+};
+
+$getInventory = function ($response) {
+	return (int) current($response->response->docs[0]->getChildDocuments()[0]['inventory_i']->values);
 +};
+
+$options = array (
+		'hostname' => SOLR_SERVER_HOSTNAME,
+		'login' => SOLR_SERVER_USERNAME,
+		'password' => SOLR_SERVER_PASSWORD,
+		'port' => SOLR_SERVER_PORT,
+		'path' => SOLR_SERVER_STORE_PATH,
+		'wt' => 'xml' 
+);
+
+$client = new SolrClient ( $options );
+
+$query = new SolrQuery ('id:1 AND {!parent which=$parentFilter}');
+
+$query->setParam ( 'parentFilter', 'content_type_s:product' );
+$query->addFilterQuery('{!parent which=$parentFilter}');
+
+$query->addField ( '*' );
+$query->addField ( '[child parentFilter=$parentFilter]' );
+
+$query->setStart ( 0 );
+$query->setRows ( 1 );
+
+// query existing inventory
+$queryResponse = $client->query ( $query );
+$queryResponse->setParseMode(SolrResponse::PARSE_SOLR_DOC);
+$response = $queryResponse->getResponse();
+$existingInventory = $getInventory($response);
+
+// update inventory to 300
+$document = $response->response->docs[0]->getInputDocument();
+$updateInventory($document, 300);
+$client->addDocument($document);
+$client->commit();
+
+// fetch the document again after the update
+$queryResponse = $client->query ( $query );
+$queryResponse->setParseMode(SolrResponse::PARSE_SOLR_DOC);
+$response = $queryResponse->getResponse();
+$newInventory = $getInventory($response);
+assert($newInventory == 300);
+
+
+echo "------EXISTING------" . PHP_EOL;
+var_dump($existingInventory);
+echo "----AFTER UPDATE----" . PHP_EOL;
+var_dump($newInventory);
+
+// cleanup: restore document's original state
+$document = $response->response->docs[0]->getInputDocument();
+$updateInventory($document, $existingInventory);
+$client->addDocument($document);
+$client->commit();
+?>
+--EXPECT--
+------EXISTING------
+int(200)
+----AFTER UPDATE----
+int(300)
\ No newline at end of file



-- 
PECL CVS Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic