Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some improvements to example code #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is useful to show what $attribute is for.

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<?php
class CheckAllWidgetTest extends WebTestCase

class CheckAllWidgetTest extends CWebTestCase
{
/**
* Sets up before each test method runs.
*/
protected function setUp()
{
parent::setUp();
// set the base URL for the test application.
$this->setBrowserUrl('http://localhost/test-application');
}

public function testWidget()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no WebTestCase in example code you should copy code from default app here and extend CWebTestCase so it is more clear what's going on.

{
$this->open('check/index');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix has to be done to not get an exception about converting CDbExpression to string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed that still $post->created_on can be a string, so a strtotime() should be added too.

}