1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\ActivityContactBundle\Tests\Integration\Command; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
6
|
|
|
|
7
|
|
|
use Monolog\Registry; |
8
|
|
|
|
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
10
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
11
|
|
|
|
12
|
|
|
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase; |
13
|
|
|
|
14
|
|
|
use OroCRM\Bundle\ActivityContactBundle\Command\ActivityContactRecalculateCommand; |
15
|
|
|
use OroCRM\Bundle\ContactBundle\Tests\Functional\DataFixtures\LoadContactEntitiesData; |
16
|
|
|
use OroCRM\Bundle\DotmailerBundle\Entity\Contact; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @outputBuffering enabled |
20
|
|
|
* @dbIsolation |
21
|
|
|
*/ |
22
|
|
|
class ActivityContactRecalculateCommandTest extends WebTestCase |
23
|
|
|
{ |
24
|
|
|
public function setUp() |
25
|
|
|
{ |
26
|
|
|
$this->initClient(); |
27
|
|
|
$this->loadFixtures([ |
28
|
|
|
'OroCRM\Bundle\ContactBundle\Tests\Functional\DataFixtures\LoadContactEntitiesData', |
29
|
|
|
]); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testRecalculationOfContactedContactHavingNoActivities() |
33
|
|
|
{ |
34
|
|
|
$firstContact = $this->findContact(LoadContactEntitiesData::FIRST_ENTITY_NAME); |
35
|
|
|
|
36
|
|
|
$firstContact->setAcContactCount(1); |
37
|
|
|
$this->getEntityManager()->flush(); |
38
|
|
|
$this->runActivityContactRecalculateCommand(); |
39
|
|
|
$firstContact = $this->findContact(LoadContactEntitiesData::FIRST_ENTITY_NAME); |
40
|
|
|
|
41
|
|
|
$this->assertEquals(0, $firstContact->getAcContactCount()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function runActivityContactRecalculateCommand() |
45
|
|
|
{ |
46
|
|
|
$app = new Application($this->getContainer()->get('kernel')); |
47
|
|
|
$app->setAutoExit(false); |
48
|
|
|
$app->run(new ArrayInput([ |
49
|
|
|
'command' => ActivityContactRecalculateCommand::COMMAND_NAME, |
50
|
|
|
])); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $firstName |
55
|
|
|
* |
56
|
|
|
* @return Contact |
57
|
|
|
*/ |
58
|
|
|
protected function findContact($firstName) |
59
|
|
|
{ |
60
|
|
|
return $this->getRegistry()->getRepository('OroCRMContactBundle:Contact')->findOneByFirstName($firstName); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return EntityManager |
65
|
|
|
*/ |
66
|
|
|
protected function getEntityManager() |
67
|
|
|
{ |
68
|
|
|
return $this->getRegistry()->getManager(); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return Registry |
73
|
|
|
*/ |
74
|
|
|
protected function getRegistry() |
75
|
|
|
{ |
76
|
|
|
return $this->getContainer()->get('doctrine'); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.