-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from totten/master-polyfill
Apply update polyfill. Add test coverage for generating multiple extensions. (#257)
- Loading branch information
Showing
2 changed files
with
72 additions
and
2 deletions.
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,69 @@ | ||
<?php | ||
|
||
namespace E2E; | ||
|
||
use ProcessHelper\ProcessHelper as PH; | ||
|
||
/** | ||
* For this test, we create and enable two extensions. | ||
* They should coexist. | ||
*/ | ||
class MultiExtensionTest extends \PHPUnit\Framework\TestCase { | ||
|
||
use CivixProjectTestTrait; | ||
|
||
public static $keys = ['apple', 'banana']; | ||
|
||
public static $key = '**INVALID**'; | ||
|
||
public function setUp(): void { | ||
chdir(static::getWorkspacePath()); | ||
PH::runOk('civibuild restore'); | ||
|
||
foreach (static::$keys as $key) { | ||
static::cleanDir($key); | ||
$this->civixGenerateModule($key); | ||
} | ||
|
||
foreach ($this->visitExts() as $name) { | ||
$this->assertFileGlobs([ | ||
'info.xml' => 1, | ||
"$name.php" => 1, | ||
"$name.civix.php" => 1, | ||
]); | ||
} | ||
} | ||
|
||
protected function tearDown(): void { | ||
chdir(static::getWorkspacePath()); | ||
PH::runOk('civibuild restore'); | ||
} | ||
|
||
public function testAddPage(): void { | ||
foreach ($this->visitExts() as $name) { | ||
$camel = ucfirst($name); | ||
$this->assertFileGlobs(["CRM/$camel/Page/My$camel.php" => 0]); | ||
$this->civixGeneratePage("My$camel", "civicrm/example/$name"); | ||
$this->assertFileGlobs(["CRM/$camel/Page/My$camel.php" => 1]); | ||
|
||
PH::runOK('cv en ' . escapeshellarg($name)); | ||
} | ||
|
||
foreach ($this->visitExts() as $name) { | ||
$camel = ucfirst($name); | ||
$getPage = PH::runOK("cv api4 Route.get +w path=civicrm/example/$name +s page_callback"); | ||
$this->assertTrue((bool) preg_match("/CRM_{$camel}_Page_My{$camel}/", $getPage->getOutput()), "Route 'civicrm/example/$name' should be registered"); | ||
} | ||
} | ||
|
||
protected function visitExts(): \Generator { | ||
foreach (static::$keys as $key) { | ||
static::$key = $key; | ||
chdir(static::getWorkspacePath()); | ||
chdir($key); | ||
yield $key; | ||
} | ||
chdir(static::getWorkspacePath()); | ||
} | ||
|
||
} |