Blame view

vendor/rmrevin/yii2-fontawesome/tests/unit/TestCase.php 1.82 KB
e9aa73b0   andryeyev   + adminLte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  <?php
  /**
   * TestCase.php
   * @author Revin Roman
   * @link https://rmrevin.ru
   */
  
  namespace rmrevin\yii\fontawesome\tests\unit;
  
  use yii\helpers\ArrayHelper;
  
  /**
   * Class TestCase
   * @package rmrevin\yii\fontawesome\tests\unit
   * This is the base class for all yii framework unit tests.
   */
  abstract class TestCase extends \PHPUnit_Framework_TestCase
  {
  
      public static $params;
  
      protected function setUp()
      {
          parent::setUp();
          $this->mock_application();
      }
  
      /**
       * Populates Yii::$app with a new application
       * The application will be destroyed on tearDown() automatically.
       * @param string $appClass
       */
      protected function mock_application($appClass = '\yii\console\Application')
      {
          // for update self::$params
          $this->get_param('id');
  
          /** @var \yii\console\Application $app */
          new $appClass(self::$params);
      }
  
      /**
       * Returns a test configuration param from /data/config.php
       * @param string $name params name
       * @param mixed $default default value to use when param is not set.
       * @return mixed the value of the configuration param
       */
      public function get_param($name, $default = null)
      {
          if (self::$params === null) {
              self::$params = require(__DIR__ . '/config/main.php');
              $main_local = __DIR__ . '/config/main-local.php';
              if (file_exists($main_local)) {
                  self::$params = ArrayHelper::merge(self::$params, require($main_local));
              }
          }
  
          return isset(self::$params[$name]) ? self::$params[$name] : $default;
      }
  
      protected function tearDown()
      {
          parent::tearDown();
      }
  
      /**
       * Destroys application in Yii::$app by setting it to null.
       */
      protected function destroy_application()
      {
          \Yii::$app = null;
      }
  }