|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Wabel\Zoho\CRM\Service; |
|
4
|
|
|
|
|
5
|
|
|
use Psr\Log\NullLogger; |
|
6
|
|
|
use Wabel\Zoho\CRM\AbstractZohoDao; |
|
7
|
|
|
use Wabel\Zoho\CRM\ZohoClient; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class EntitiesGeneratorServiceTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var ZohoClient |
|
14
|
|
|
*/ |
|
15
|
|
|
private $zohoClient; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var EntitiesGeneratorService |
|
19
|
|
|
*/ |
|
20
|
|
|
private $entitiesGeneratorService; |
|
21
|
|
|
|
|
22
|
|
|
protected function setUp() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->zohoClient = new ZohoClient( |
|
25
|
|
|
[ |
|
26
|
|
|
'client_id' => getenv('client_id'), |
|
27
|
|
|
'client_secret' => getenv('client_secret'), |
|
28
|
|
|
'redirect_uri' => getenv('redirect_uri'), |
|
29
|
|
|
'currentUserEmail' => getenv('currentUserEmail'), |
|
30
|
|
|
'applicationLogFilePath' => getenv('applicationLogFilePath'), |
|
31
|
|
|
'persistence_handler_class' => getenv('persistence_handler_class'), |
|
32
|
|
|
'token_persistence_path' => getenv('token_persistence_path'), |
|
33
|
|
|
] |
|
34
|
|
|
); |
|
35
|
|
|
$this->entitiesGeneratorService = new EntitiesGeneratorService($this->zohoClient, new NullLogger()); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testGenerateAll() |
|
39
|
|
|
{ |
|
40
|
|
|
$zohoModulesDaos = $this->entitiesGeneratorService->generateAll(__DIR__.'/../generated/', 'TestNamespace'); |
|
41
|
|
|
$this->assertContains('TestNamespace\\LeadZohoDao', $zohoModulesDaos); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testGenerateModule() |
|
45
|
|
|
{ |
|
46
|
|
|
|
|
47
|
|
|
$this->entitiesGeneratorService->generateModule('Leads', 'Leads', 'Lead', __DIR__.'/../generated/', 'TestNamespace'); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertFileExists(__DIR__.'/../generated/Lead.php'); |
|
50
|
|
|
|
|
51
|
|
|
require __DIR__.'/../generated/Lead.php'; |
|
52
|
|
|
|
|
53
|
|
|
// Second iteration: from existing class! |
|
54
|
|
|
$daoFullyQualified = $this->entitiesGeneratorService->generateModule('Leads', 'Leads', 'Lead', __DIR__.'/../generated/', 'TestNamespace'); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertFileExists(__DIR__.'/../generated/Lead.php'); |
|
57
|
|
|
$this->assertEquals('TestNamespace\\LeadZohoDao', $daoFullyQualified); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|