Skip to content

Commit

Permalink
Tests update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pol Dellaiera authored and Pol Dellaiera committed Jun 5, 2015
1 parent a6d4eb2 commit 21bef18
Showing 1 changed file with 60 additions and 10 deletions.
70 changes: 60 additions & 10 deletions tests/src/Messenger/LegacyMessengerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LegacyMessengerTest extends \PHPUnit_Framework_TestCase {
*
* @var \Drupal\service_container\Legacy\Drupal7
*/
protected $drupal7_service;
protected $drupal7;

/**
* The Messenger service.
Expand All @@ -34,41 +34,91 @@ class LegacyMessengerTest extends \PHPUnit_Framework_TestCase {
protected function setUp() {
parent::setUp();

$this->drupal7_service = new Drupal7();
$this->messenger_service = new LegacyMessenger($this->drupal7_service);
// We can't use the mock object here because LegacyMessenger needs a
// \Drupal\service_container\Legacy\Drupal7 argument.
// Do we need to create an interface for it instead ?
$this->drupal7 = new Drupal7();
$this->messenger_service = new LegacyMessenger($this->drupal7);
}

/**
* @covers ::__construct()
*/
public function test_construct() {
$this->assertInstanceOf('\Drupal\service_container\Messenger\LegacyMessenger', $this->messenger_service);
$this->assertInstanceOf('\Drupal\service_container\Legacy\Drupal7', $this->drupal7_service);
$this->assertInstanceOf('\Drupal\service_container\Messenger\MessengerInterface', $this->messenger_service);
$this->assertInstanceOf('\Drupal\service_container\Legacy\Drupal7', $this->drupal7);
}

/**
* @covers ::addMessage()
*/
public function test_addMessage() {}
public function test_addMessage() {
$drupal7 = \Mockery::mock('Drupal\service_container\Legacy\Drupal7');
$message = 'Izumi';
$type = 'warning';

$drupal7
->shouldReceive('drupal_set_message')
->once()
->with($message, $type, FALSE);

$this->messenger_service->addMessage($message, $type);
}

/**
* @covers ::getMessages()
*/
public function test_getMessages() {}
public function test_getMessages() {
$drupal7 = \Mockery::mock('Drupal\service_container\Legacy\Drupal7');

$drupal7
->shouldReceive('drupal_get_messages')
->once()
->with(NULL, FALSE);

$this->messenger_service->getMessages();
}

/**
* @covers ::getMessagesByType()
*/
public function test_getMessagesByType() {}
public function test_getMessagesByType() {
$drupal7 = \Mockery::mock('Drupal\service_container\Legacy\Drupal7');

$drupal7
->shouldReceive('drupal_get_messages')
->once()
->with('warning', FALSE);

$this->messenger_service->getMessages('warning');
}

/**
* @covers ::deleteMessages()
*/
public function test_deleteMessages() {}
public function test_deleteMessages() {
$drupal7 = \Mockery::mock('Drupal\service_container\Legacy\Drupal7');

$drupal7
->shouldReceive('drupal_get_messages')
->once()
->with(NULL, TRUE);

$this->messenger_service->deleteMessages();
}

/**
* @covers ::deleteMessagesByType()
*/
public function test_deleteMessagesByType() {}
public function test_deleteMessagesByType() {
$drupal7 = \Mockery::mock('Drupal\service_container\Legacy\Drupal7');

$drupal7
->shouldReceive('drupal_get_messages')
->once()
->with('warning', TRUE);

$this->messenger_service->deleteMessagesByType('warning');
}

}

0 comments on commit 21bef18

Please sign in to comment.