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

Demonstrate the OPTIONS HTTP method unit testing #15

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
6 changes: 6 additions & 0 deletions app/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,11 @@
$app->response->write($response);
});

// Options method support
$app->options('/cors', function () use ($app) {
$app->response->setStatus(200);
$app->response->headers->set('Access-Control-Allow-Origin', '*');
});


/* End of file app.php */
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"indeyets/pake": "~1.99",
"shuber/curl": "dev-master",
"slim/slim": "2.4.*",
"slim/slim": "2.6.*",
"slim/views": "0.1.*",
"there4/slim-test-helpers": "dev-master",
"twig/twig": "1.15.0"
Expand Down
33 changes: 17 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/integration/OptionsMethodTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class OptionsMethodTest extends LocalWebTestCase
{
public function testCORS()
{
$this->client->options('/cors');
$this->assertEquals(200, $this->client->response->status());
$this->assertSame('*', $this->client->response->headers['Access-Control-Allow-Origin']);
}
}

/* End of file OptionsMethodTest.php */