-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix #160 Fix bad call at
TicketManager::getTicketList()
(phansys)
This PR was merged into the 3.x branch. Discussion ---------- |Q |A | |--- |---| |Branch |3.x| |Bug fix? |yes| |New feature? |no | |BC breaks? |no | |Deprecations?|no | |Tests pass? |yes| |Fixed tickets|n/a| |License |MIT| |Doc PR |n/a| Issue introduced at be8f77a. Commits ------- e2e7343 Fix bad call at `TicketManager::getTicketList()`
- Loading branch information
Showing
2 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace Hackzilla\Bundle\TicketBundle\Tests\User; | ||
|
||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Doctrine\ORM\EntityRepository; | ||
use Doctrine\ORM\QueryBuilder; | ||
use Hackzilla\Bundle\TicketBundle\Manager\TicketManager; | ||
use Hackzilla\Bundle\TicketBundle\Manager\UserManagerInterface; | ||
use Hackzilla\Bundle\TicketBundle\Model\TicketMessageInterface; | ||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
/** | ||
* @author Javier Spagnoletti <phansys@gmail.com> | ||
*/ | ||
final class TicketManagerTest extends WebTestCase | ||
{ | ||
/** | ||
* @var UserManagerInterface | ||
*/ | ||
private $userManager; | ||
|
||
protected function setUp() | ||
{ | ||
$this->userManager = $this->createMock(UserManagerInterface::class); | ||
$this->userManager | ||
->method('getCurrentUser') | ||
->willReturn('ANONYMOUS'); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
unset($this->userManager); | ||
} | ||
|
||
public function testGetTicketListQuery() | ||
{ | ||
$ticketClass = 'App\Ticket'; | ||
$ticketMessageClass = 'App\TicketMessage'; | ||
|
||
$qb = $this->createMock(QueryBuilder::class); | ||
$qb | ||
->method('orderBy') | ||
->willReturn($qb); | ||
$qb | ||
->method('andWhere') | ||
->willReturn($qb); | ||
$entityRepository = $this->createMock(EntityRepository::class); | ||
$entityRepository | ||
->method('createQueryBuilder') | ||
->willReturn($qb); | ||
|
||
$om = $this->createMock(ObjectManager::class); | ||
$om | ||
->method('getRepository') | ||
->willReturn($entityRepository); | ||
|
||
$ticketManager = new TicketManager($ticketClass, $ticketMessageClass); | ||
$ticketManager->setEntityManager($om); | ||
|
||
$this->assertInstanceOf(QueryBuilder::class, $ticketManager->getTicketListQuery($this->userManager, TicketMessageInterface::STATUS_OPEN)); | ||
} | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method. | ||
* | ||
* @group legacy | ||
* | ||
* @expectedDeprecation Method `Hackzilla\Bundle\TicketBundle\Manager\TicketManager::getTicketList()` is deprecated since hackzilla/ticket-bundle 3.3 and will be removed in version 4.0. Use `Hackzilla\Bundle\TicketBundle\Manager\TicketManager::getTicketListQuery()` instead. | ||
*/ | ||
public function testGetTicketList() | ||
{ | ||
$ticketClass = 'App\Ticket'; | ||
$ticketMessageClass = 'App\TicketMessage'; | ||
|
||
$qb = $this->createMock(QueryBuilder::class); | ||
$qb | ||
->method('orderBy') | ||
->willReturn($qb); | ||
$qb | ||
->method('andWhere') | ||
->willReturn($qb); | ||
$entityRepository = $this->createMock(EntityRepository::class); | ||
$entityRepository | ||
->method('createQueryBuilder') | ||
->willReturn($qb); | ||
|
||
$om = $this->createMock(ObjectManager::class); | ||
$om | ||
->method('getRepository') | ||
->willReturn($entityRepository); | ||
|
||
$ticketManager = new TicketManager($ticketClass, $ticketMessageClass); | ||
$ticketManager->setEntityManager($om); | ||
|
||
$this->assertInstanceOf(QueryBuilder::class, $ticketManager->getTicketList($this->userManager, TicketMessageInterface::STATUS_OPEN)); | ||
} | ||
} |