Interim commit.
[yaffs-website] / web / modules / contrib / pathauto / tests / src / Unit / VerboseMessengerTest.php
1 <?php
2
3 namespace Drupal\Tests\pathauto\Unit {
4
5   use Drupal\pathauto\VerboseMessenger;
6   use Drupal\Tests\UnitTestCase;
7
8   /**
9    * @coversDefaultClass \Drupal\pathauto\VerboseMessenger
10    * @group pathauto
11    */
12   class VerboseMessengerTest extends UnitTestCase {
13
14     /**
15      * The messenger under test.
16      *
17      * @var \Drupal\pathauto\VerboseMessenger
18      */
19     protected $messenger;
20
21     /**
22      * {@inheritdoc}
23      */
24     protected function setUp() {
25       $config_factory = $this->getConfigFactoryStub(array('pathauto.settings' => array('verbose' => TRUE)));
26       $account = $this->getMock('\Drupal\Core\Session\AccountInterface');
27       $account->expects($this->once())
28         ->method('hasPermission')
29         ->withAnyParameters()
30         ->willReturn(TRUE);
31
32       $this->messenger = new VerboseMessenger($config_factory, $account);
33     }
34
35     /**
36      * Tests add messages.
37      * @covers ::addMessage
38      */
39     public function testAddMessage() {
40       $this->assertTrue($this->messenger->addMessage("Test message"), "The message was added");
41     }
42
43     /**
44      * @covers ::addMessage
45      */
46     public function testDoNotAddMessageWhileBulkupdate() {
47       $this->assertFalse($this->messenger->addMessage("Test message", "bulkupdate"), "The message was NOT added");
48     }
49
50 }
51
52 }
53 namespace {
54   // @todo Delete after https://drupal.org/node/1858196 is in.
55   if (!function_exists('drupal_set_message')) {
56     function drupal_set_message() {
57     }
58   }
59 }