Last active
August 29, 2015 14:02
-
-
Save Chrysweel/bbf4d6454c1822eac57b to your computer and use it in GitHub Desktop.
Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testSecurityRolesCanCreateChannelAction() | |
{ | |
// Create a new client to browse the application | |
$client = static::createClient(); | |
$mock_event_dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface') | |
->disableOriginalConstructor() | |
->getMock(); | |
static::$kernel->getContainer()->set('event_dispatcher', $mock_event_dispatcher); | |
// $client->getContainer()->set('event_dispatcher', $mock_event_dispatcher); | |
$url = sprintf('/api/channels.json?access_token=%s',$this->getOAuthAccessTokenUserEnabled()); | |
$parameters = array( | |
'name' => 'name_moderator', | |
'irc_channel' => '#name_moderator', | |
'description' => 'Description of test moderator', | |
'channel_type' => 'adult' | |
); | |
// Create a new entry in the database | |
$client->request( | |
'POST', | |
$url, | |
$parameters, | |
array(), | |
array('HTTP_Accept' => 'application/json') | |
); | |
$response = $client->getResponse(); | |
$this->assertEquals(201, $response->getStatusCode(), "Unexpected HTTP status code for GET /api/channels/create..."); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
static protected function createClient(array $options = array(), array $server = array()) | |
{ | |
if (null !== static::$kernel) { | |
static::$kernel->shutdown(); | |
} | |
static::$kernel = static::createKernel($options); | |
static::$kernel->boot(); | |
$client = static::$kernel->getContainer()->get('test.client'); | |
$client->setServerParameters($server); | |
return $client; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment