Esempio n. 1
0
 public function testGetByEmail()
 {
     $bxObject = m::mock('object');
     TestUser::$bxObject = $bxObject;
     $bxObject->shouldReceive('getList')->with(['SORT' => 'ASC'], false, ['EMAIL' => '*****@*****.**'], ['SELECT' => false, 'NAV_PARAMS' => ['nPageSize' => 1], 'FIELDS' => ['ID', 'NAME']])->once()->andReturn(m::self());
     $bxObject->shouldReceive('fetch')->times(2)->andReturn(['ID' => 1, 'NAME' => 'foo'], false);
     $query = $this->createQuery($bxObject);
     $item = $query->sort(['SORT' => 'ASC'])->select('ID', 'NAME')->getByEmail('*****@*****.**');
     $this->assertSame(['ID' => 1, 'NAME' => 'foo'], $item->toArray());
 }
Esempio n. 2
0
 public function testFill()
 {
     $user = new TestUser(1);
     $fields = ['ID' => 2, 'NAME' => 'John Doe', 'GROUP_ID' => [1, 2]];
     $user->fill($fields);
     $this->assertSame(2, $user->id);
     $this->assertSame($fields, $user->fields);
     $this->assertSame($fields, $user->get());
     $bxObject = m::mock('object');
     $bxObject->shouldReceive('getUserGroup')->once()->andReturn([1]);
     TestUser::$bxObject = $bxObject;
     $user = new TestUser(1);
     $fields = ['ID' => 2, 'NAME' => 'John Doe'];
     $user->fill($fields);
     $this->assertSame(2, $user->id);
     $this->assertSame($fields, $user->fields);
     $this->assertSame($fields + ['GROUP_ID' => [1]], $user->get());
 }