/**
  * Create a test group.
  *
  * @param CustomerGroup $group The group to create and save.
  * @return int The group Id of the group that was created.
  */
 private function createGroup($group)
 {
     $groupId = $this->groupRepository->save($group)->getId();
     $this->assertNotNull($groupId);
     $newGroup = $this->groupRepository->getById($groupId);
     $this->assertEquals($groupId, $newGroup->getId(), 'The group id does not match.');
     $this->assertEquals($group->getCode(), $newGroup->getCode(), 'The group code does not match.');
     $this->assertEquals($group->getTaxClassId(), $newGroup->getTaxClassId(), 'The group tax class id does not match.');
     $this->groupRegistry->remove($groupId);
     return $groupId;
 }
Exemplo n.º 2
0
 public function testGetById()
 {
     $groupId = 86;
     $this->groupRegistry->expects($this->once())->method('retrieve')->with($groupId)->willReturn($this->groupModel);
     $this->groupDataFactory->expects($this->once())->method('create')->willReturn($this->group);
     $this->group->expects($this->once())->method('setId')->with($groupId)->willReturnSelf();
     $this->group->expects($this->once())->method('setCode')->with('Code')->willReturnSelf();
     $this->group->expects($this->once())->method('setTaxClassId')->with(234)->willReturnSelf();
     $this->group->expects($this->once())->method('setTaxClassName')->with('Tax class name')->willReturnSelf();
     $this->groupModel->expects($this->atLeastOnce())->method('getId')->willReturn($groupId);
     $this->groupModel->expects($this->atLeastOnce())->method('getCode')->willReturn('Code');
     $this->groupModel->expects($this->atLeastOnce())->method('getTaxClassId')->willReturn(234);
     $this->groupModel->expects($this->atLeastOnce())->method('getTaxClassName')->willReturn('Tax class name');
     $this->assertSame($this->group, $this->model->getById($groupId));
 }