Exemplo n.º 1
0
 public function testFill()
 {
     TestSection::$bxObject = m::mock('object');
     $section = new TestSection(1);
     $fields = ['ID' => 2, 'NAME' => 'Section 1'];
     $section->fill($fields);
     $this->assertSame(2, $section->id);
     $this->assertSame($fields, $section->fields);
     $this->assertSame($fields, $section->get());
 }
Exemplo n.º 2
0
 public function testGetListWithScopes()
 {
     $bxObject = m::mock('object');
     TestSection::$bxObject = $bxObject;
     $bxObject->shouldReceive('getList')->with(['SORT' => 'ASC'], ['NAME' => 'John', 'ACTIVE' => 'Y', 'IBLOCK_ID' => 1], false, ['ID', 'NAME'], false)->once()->andReturn(m::self());
     $bxObject->shouldReceive('fetch')->andReturn(['ID' => 1, 'NAME' => 'foo'], ['ID' => 2, 'NAME' => 'bar'], false);
     $query = $this->createQuery($bxObject);
     $items = $query->sort(['SORT' => 'ASC'])->filter(['NAME' => 'John'])->active()->select('ID', 'NAME')->getList();
     $expected = [1 => ['ID' => 1, 'NAME' => 'foo'], 2 => ['ID' => 2, 'NAME' => 'bar']];
     foreach ($items as $k => $item) {
         $this->assertSame($expected[$k], $item->toArray());
     }
 }