Author: chrisk
Date: 2010-02-20 15:02:31 +0100 (Sat, 20 Feb 2010)
New Revision: 28148
Modified:
plugins/ckWebServicePlugin/branches/1.3/README
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingDoctrineTest.php
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingPropelTest.php
Log:
[ckWebServicePlugin] updated functional tests for doctrine/propel object
mapping, so no longer object graphs with reference cycles are passed as
parameters to the webservice; updated README;
Modified: plugins/ckWebServicePlugin/branches/1.3/README
===================================================================
--- plugins/ckWebServicePlugin/branches/1.3/README 2010-02-20 01:14:00 UTC
(rev 28147)
+++ plugins/ckWebServicePlugin/branches/1.3/README 2010-02-20 14:02:31 UTC
(rev 28148)
@@ -1,4 +1,4 @@
-# ckWebServicePlugin (for symfony 1.2)
+# ckWebServicePlugin (for symfony 1.3)
The ckWebServicePlugin allows you to build a webservice api for your symfony
applications.
It comes with a powerful and easy to use wsdl generator, which creates WS-I
compliant wsdl files for a maximum of interopability with PHP, .NET and Java
clients.
@@ -13,13 +13,17 @@
To install the latest release, execute:
> symfony plugin:install ckWebServicePlugin
+
+To install the latest release from SVN, checkout the release tag into a
`plugins/ckWebServicePlugin` folder:
-or to install the current revision, checkout the HEAD revision into a
`plugins/ckWebServicePlugin` folder:
+ > svn co
http://svn.symfony-project.com/plugins/ckWebServicePlugin/tags/4.0.0/
+
+To install the latest development revision from SVN, checkout the HEAD
revision of the development branch into a `plugins/ckWebServicePlugin` folder:
- > svn co
http://svn.symfony-project.com/plugins/ckWebServicePlugin/branches/1.2/
+ > svn co
http://svn.symfony-project.com/plugins/ckWebServicePlugin/branches/1.3/
>**CAUTION**
->The HEAD revision of the branch is not guaranteed to be stable all the time!
+>The HEAD revision of the development branch is not guaranteed to be stable
all the time!
Now configure the plugin how it is described in the next section and clear
your cache afterwards.
@@ -591,6 +595,9 @@
As you see, we have added a lightweight definition of the `ComplexNumber`
class called `ClientComplexNumber`, because it is likely that you don't have
the same class definition at client and server, only the names and types of the
properties will match.
+>**TIP**
+>Do not forget to validate objects you get as a parameter!
+
Often the objects you want to return or pass in as parameter are not as simple
as the shown `ComplexNumber`, e.g. Doctrine or Propel objects or objects which
have a JavaBean-style class, so the properties are only accessible through
getter and setter methods.
The plugin also offers a solution for this problem. Therefor it introduces so
called property strategies, they have two purposes, the first is to determine
which properties a class has when the wsdl is generated, the second purpose is
to access those properties
@@ -697,8 +704,8 @@
This is everything you have to do to use such complex classes!
->**TIP**
->Do not forget to validate objects you get as a parameter!
+>**CAUTION**
+>Passing Doctrine and Propel object graphs with cyclic references as
parameters to your methods is currently not supported!
In this section you have learned how to work with arrays and classes, the next
section covers the usage of SOAP Headers.
Modified:
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingDoctrineTest.php
===================================================================
---
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingDoctrineTest.php
2010-02-20 01:14:00 UTC (rev 28147)
+++
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingDoctrineTest.php
2010-02-20 14:02:31 UTC (rev 28148)
@@ -46,26 +46,60 @@
$Articles;
}
-function checkFixtureModel(ckTestSoapClient $c)
+function checkFixtureModel(ckTestSoapClient $c, $withAuthor)
{
$c->isFaultEmpty()
->isCount('', 2)
->isType('', 'ckGenericArray')
->isType('0', 'myArticle')
+ ->is('0.id', 1)
+ ->is('0.title', 'Howto Build Webservices in Symfony')
+ ->is('0.content', 'Some Content.')
->isType('0.Authors', 'ckGenericArray')
- ->isCount('0.Authors', 1)
- ->isType('0.Authors.0', 'myAuthor')
->isType('0.Comments', 'ckGenericArray')
->isCount('0.Comments', 2)
->isType('0.Comments.0', 'myComment')
+ ->is('0.Comments.0.content', 'Physics is great!')
+ ->is('0.Comments.0.author', 'Isaac Newton')
+ ->isType('0.Comments.1', 'myComment')
+ ->is('0.Comments.1.content', 'I like cars!')
+ ->is('0.Comments.1.author', 'Henry Ford')
+ ->isType('1', 'myArticle')
+ ->is('1.id', 2)
+ ->is('1.title', 'Howto Write Tests In Symfony')
+ ->is('1.content', 'Some Content.')
+ ->isType('1.Authors', 'ckGenericArray')
+ ->isType('1.Comments', 'ckGenericArray')
+ ->isCount('1.Comments', 1)
+ ->isType('1.Comments.0', 'myComment')
+ ->is('1.Comments.0.content', 'Alles ist relativ!')
+ ->is('1.Comments.0.author', 'Albert Einstein')
;
$result = $c->getResult();
$t = $c->test();
- $t->cmp_ok($result[0]->Authors[0], '===', $result[1]->Authors[0]);
$t->cmp_ok($result[0]->Comments[0]->Article, '===',
$result[0]->Comments[1]->Article);
$t->cmp_ok($result[0], '===', $result[0]->Comments[0]->Article);
+
+ if($withAuthor)
+ {
+ $c
+ ->isCount('0.Authors', 1)
+ ->isType('0.Authors.0', 'myAuthor')
+ ->is('0.Authors.0.id', 1)
+ ->is('0.Authors.0.name', 'Christian Kerl')
+ ->isCount('1.Authors', 1)
+ ->isType('1.Authors.0', 'myAuthor')
+ ->is('1.Authors.0.id', 1)
+ ->is('1.Authors.0.name', 'Christian Kerl');
+
+ $t->cmp_ok($result[0]->Authors[0], '===', $result[1]->Authors[0]);
+ $t->cmp_ok($result[0], '===', $result[0]->Authors[0]->Articles[0]);
+ $t->cmp_ok($result[1], '===', $result[0]->Authors[0]->Articles[1]);
+ $t->cmp_ok($result[0], '===', $result[1]->Authors[0]->Articles[0]);
+ $t->cmp_ok($result[1], '===', $result[1]->Authors[0]->Articles[1]);
+ }
}
$_options = array(
@@ -81,5 +115,11 @@
$c = new ckTestSoapClient($_options);
-checkFixtureModel($c->getFixtureModel());
-checkFixtureModel($c->passFixtureModel($c->getResult()));
+checkFixtureModel($c->getFixtureModel(), true);
+
+$lastResult = $c->getResult();
+// unset Authors with cyclic reference causing problems during deserialization
at server
+$lastResult[0]->Authors = array();
+$lastResult[1]->Authors = array();
+
+checkFixtureModel($c->passFixtureModel($lastResult), false);
Modified:
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingPropelTest.php
===================================================================
---
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingPropelTest.php
2010-02-20 01:14:00 UTC (rev 28147)
+++
plugins/ckWebServicePlugin/branches/1.3/test/functional/typeMappingPropelTest.php
2010-02-20 14:02:31 UTC (rev 28148)
@@ -52,29 +52,62 @@
$name,
$ArticleAuthors;
}
-
-function checkFixtureModel(ckTestSoapClient $c)
+function checkFixtureModel(ckTestSoapClient $c, $withAuthor)
{
- $c->getFixtureModel()
- ->isFaultEmpty()
+ $c->isFaultEmpty()
->isCount('', 2)
->isType('', 'ckGenericArray')
->isType('0', 'myArticle')
+ ->is('0.id', 1)
+ ->is('0.title', 'Howto Build Webservices in Symfony')
+ ->is('0.content', 'Some Content.')
->isType('0.ArticleAuthors', 'ckGenericArray')
- ->isCount('0.ArticleAuthors', 1)
- ->isType('0.ArticleAuthors.0', 'myArticleAuthor')
- ->isType('0.ArticleAuthors.0.Author', 'myAuthor')
->isType('0.ArticleComments', 'ckGenericArray')
->isCount('0.ArticleComments', 2)
->isType('0.ArticleComments.0', 'myArticleComment')
- ;
+ ->is('0.ArticleComments.0.content', 'Physics is great!')
+ ->is('0.ArticleComments.0.author', 'Isaac Newton')
+ ->isType('0.ArticleComments.1', 'myArticleComment')
+ ->is('0.ArticleComments.1.content', 'I like cars!')
+ ->is('0.ArticleComments.1.author', 'Henry Ford')
+ ->isType('1', 'myArticle')
+ ->is('1.id', 2)
+ ->is('1.title', 'Howto Write Tests In Symfony')
+ ->is('1.content', 'Some Content.')
+ ->isType('1.ArticleAuthors', 'ckGenericArray')
+ ->isType('1.ArticleComments', 'ckGenericArray')
+ ->isCount('1.ArticleComments', 1)
+ ->isType('1.ArticleComments.0', 'myArticleComment')
+ ->is('1.ArticleComments.0.content', 'Alles ist relativ!')
+ ->is('1.ArticleComments.0.author', 'Albert Einstein')
+ ;
$result = $c->getResult();
$t = $c->test();
- $t->cmp_ok($result[0]->ArticleAuthors[0]->Author, '===',
$result[1]->ArticleAuthors[0]->Author);
$t->cmp_ok($result[0]->ArticleComments[0]->Article, '===',
$result[0]->ArticleComments[1]->Article);
$t->cmp_ok($result[0], '===', $result[0]->ArticleComments[0]->Article);
+
+ if($withAuthor)
+ {
+ $c
+ ->isCount('0.ArticleAuthors', 1)
+ ->isType('0.ArticleAuthors.0', 'myArticleAuthor')
+ ->isType('0.ArticleAuthors.0.Author', 'myAuthor')
+ ->is('0.ArticleAuthors.0.Author.id', 1)
+ ->is('0.ArticleAuthors.0.Author.name', 'Christian Kerl')
+ ->isCount('0.ArticleAuthors.0.Author.ArticleAuthors', 2)
+ ->isCount('1.ArticleAuthors', 1)
+ ->isType('1.ArticleAuthors.0', 'myArticleAuthor')
+ ->isType('1.ArticleAuthors.0.Author', 'myAuthor')
+ ->is('1.ArticleAuthors.0.Author.id', 1)
+ ->is('1.ArticleAuthors.0.Author.name', 'Christian Kerl')
+ ->isCount('1.ArticleAuthors.0.Author.ArticleAuthors', 2);
+
+ $t->ok($result[0]->ArticleAuthors[0]->Author ===
$result[1]->ArticleAuthors[0]->Author);
+ $t->ok($result[0] === $result[0]->ArticleAuthors[0]->Article);
+ $t->ok($result[1] === $result[1]->ArticleAuthors[0]->Article);
+ }
}
$_options = array(
@@ -92,5 +125,11 @@
$c = new ckTestSoapClient($_options);
-checkFixtureModel($c->getFixtureModel());
-checkFixtureModel($c->passFixtureModel($c->getResult()));
\ No newline at end of file
+checkFixtureModel($c->getFixtureModel(), true);
+
+$lastResult = $c->getResult();
+// unset ArticleAuthors with cyclic reference causing problems during
deserialization at server
+$lastResult[0]->ArticleAuthors = array();
+$lastResult[1]->ArticleAuthors = array();
+
+checkFixtureModel($c->passFixtureModel($lastResult), false);
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.