From fb3d6850e040c4c4efcb0a0d9b572523f8523d8c Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 19 Dec 2012 21:44:42 +0100 Subject: [PATCH] some improvements to example code --- .../protected/models/SiteConfirmation.php | 2 +- .../tests/functional/CheckAllWidgetTest.php | 13 ++++++++++++- .../protected/controllers/TestController.php | 7 ++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/04/writing_your_own_validators/protected/models/SiteConfirmation.php b/04/writing_your_own_validators/protected/models/SiteConfirmation.php index 0ec00f7..ade5401 100644 --- a/04/writing_your_own_validators/protected/models/SiteConfirmation.php +++ b/04/writing_your_own_validators/protected/models/SiteConfirmation.php @@ -12,7 +12,7 @@ public function rules() public function confirm($attribute,$params) { $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $this->url); + curl_setopt($ch, CURLOPT_URL, $this->$attribute); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); diff --git a/05/testing_the_application_with_functional_tests/protected/tests/functional/CheckAllWidgetTest.php b/05/testing_the_application_with_functional_tests/protected/tests/functional/CheckAllWidgetTest.php index 3b7cc66..8fae9bf 100644 --- a/05/testing_the_application_with_functional_tests/protected/tests/functional/CheckAllWidgetTest.php +++ b/05/testing_the_application_with_functional_tests/protected/tests/functional/CheckAllWidgetTest.php @@ -1,6 +1,17 @@ setBrowserUrl('http://localhost/test-application'); + } + public function testWidget() { $this->open('check/index'); diff --git a/06/automating_timestamps/protected/controllers/TestController.php b/06/automating_timestamps/protected/controllers/TestController.php index 36d2ad7..aff910f 100644 --- a/06/automating_timestamps/protected/controllers/TestController.php +++ b/06/automating_timestamps/protected/controllers/TestController.php @@ -7,6 +7,11 @@ public function actionIndex() $post->title = "test title"; $post->text = "test text"; $post->save(); - echo date('r', $post->created_on); + + // we need to refresh the model since CTimestampBehavior uses + // CDbExpression to set creation date which has to be evaluated by the database + $post->refresh(); + + echo "Post has been created on " . date('r', $post->created_on); } } \ No newline at end of file