Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Annotation / PluralTranslationTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Annotation;
4
5 use Drupal\Core\Annotation\PluralTranslation;
6 use Drupal\Tests\UnitTestCase;
7
8 /**
9  * @coversDefaultClass \Drupal\Core\Annotation\PluralTranslation
10  * @group Annotation
11  */
12 class PluralTranslationTest extends UnitTestCase {
13
14   /**
15    * @covers ::get
16    *
17    * @dataProvider providerTestGet
18    */
19   public function testGet(array $values) {
20     $annotation = new PluralTranslation($values);
21
22     $default_values = [
23       'context' => NULL,
24     ];
25     $this->assertEquals($values + $default_values, $annotation->get());
26   }
27
28   /**
29    * Provides data to self::testGet().
30    */
31   public function providerTestGet() {
32     $data = [];
33     $data[] = [
34       [
35         'singular' => $this->randomMachineName(),
36         'plural' => $this->randomMachineName(),
37         'context' => $this->randomMachineName(),
38       ],
39     ];
40     $data[] = [
41       [
42         'singular' => $this->randomMachineName(),
43         'plural' => $this->randomMachineName(),
44       ],
45     ];
46
47     return $data;
48   }
49
50   /**
51    * @dataProvider providerTestMissingData
52    */
53   public function testMissingData($data) {
54     $this->setExpectedException(\InvalidArgumentException::class);
55     new PluralTranslation($data);
56   }
57
58   public function providerTestMissingData() {
59     $data = [];
60     $data['all-missing'] = [[]];
61     $data['singular-missing'] = [['plural' => 'muh']];
62     $data['plural-missing'] = [['singular' => 'muh']];
63     return $data;
64   }
65
66 }