Example #1
0
 /**
  * @inheritdoc
  */
 public function __construct($expression, $params = [], $config = [])
 {
     parent::__construct($expression, $params, $config);
     if ($this->query instanceof ActiveQuery) {
         $this->query->on(ActiveQuery::EVENT_ALIAS, function (Event $event) use($expression) {
             /* @var $query ActiveQuery */
             $query = $event->sender;
             $this->expression = str_replace('{a}', $query->getAlias(), $expression);
         });
         $this->expression = str_replace('{a}', $this->query->getAlias(), $expression);
     }
 }
Example #2
0
 public function testMethodA()
 {
     $mock = $this->createPartialMock(ActiveQuery::className(), ['getAlias']);
     $mock->method('getAlias')->willReturn('foo');
     /* @var $mock ActiveQuery */
     static::assertEquals('foo', $mock->a());
     static::assertEquals('foo.column', $mock->a('column'));
     static::assertEquals([], $mock->a([]));
     static::assertEquals(['foo.column'], $mock->a(['column']));
     static::assertEquals(['foo.column1', 'foo.column2'], $mock->a(['column1', 'column2']));
     static::assertEquals(['foo.column1' => 1, 'foo.column2' => 2], $mock->a(['column1' => 1, 'column2' => 2]));
 }