More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / drush / drush / tests / WatchdogTest.php
1 <?php
2
3 namespace Unish;
4
5 /**
6  * @group commands
7  */
8 class WatchdogCase extends CommandUnishTestCase
9 {
10
11     public function testWatchdog()
12     {
13         $this->setUpDrupal(1, true);
14         $this->drush('pm-enable', ['dblog']);
15
16         $eval1 = "\\Drupal::logger('drush')->notice('Unish rocks.');";
17         $this->drush('php-eval', [$eval1]);
18         $this->drush('watchdog-show', [], ['count' => 50]);
19         $output = $this->getOutput();
20         $this->assertContains('Unish rocks.', $output);
21
22         // Add a new entry with a long message with the letter 'd' and verify that watchdog-show does
23         // not print it completely in the listing unless --full is given.
24         // As the output is formatted so lines may be splitted, assertContains does not work
25         // in this scenario. Therefore, we will count the number of times a character is present.
26         $message_chars = 300;
27         $char = '*';
28         $message = str_repeat($char, $message_chars);
29         $eval2 = "\\Drupal::logger('drush')->notice('$message');";
30         $this->drush('php-eval', [$eval2]);
31         $this->drush('watchdog-show');
32         $output = $this->getOutput();
33         $this->assertGreaterThan(substr_count($output, $char), $message_chars);
34         $this->drush('watchdog-show', [], ['extended' => null]);
35         $output = $this->getOutput();
36         $this->assertGreaterThanOrEqual($message_chars, substr_count($output, $char));
37
38         // Tests message deletion
39         $this->drush('watchdog-delete', ['all']);
40         $output = $this->getOutput();
41         $this->drush('watchdog-show');
42         $output = $this->getOutput();
43         $this->assertEmpty($output);
44     }
45 }