Skip to content

Commit

Permalink
Changed plugin generator to use tests/bootstrap.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jamielsharief committed Aug 29, 2020
1 parent 77b3ceb commit efa85b2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [3.3.1] - 2020-08-29

### Changed

- Changed plugin generator to use tests/bootstrap.php

## [3.3.0] - 2020-08-15

### Added
Expand Down
6 changes: 6 additions & 0 deletions src/Console/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,12 @@ public function plugin(array $data)
PLUGINS.DS.Inflector::underscored($data['class']).DS.'composer.json',
$data
);

$this->generate(
$this->getTemplateFilename('plugin_test_bootstrap'),
PLUGINS.DS.Inflector::underscored($data['class']) . DS . 'tests' . DS . 'bootstrap.php',
$data
);
}
/*
%model% e.g. BookmarksTag
Expand Down
2 changes: 1 addition & 1 deletion templates/generator/phpunit.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" processIsolation="false" stopOnFailure="false" bootstrap="../../config/bootstrap.php" backupGlobals="true">
<phpunit colors="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" backupGlobals="true">
<testsuites>
<testsuite name="Plugin Test Suite">
<directory>./tests/TestCase/</directory>
Expand Down
9 changes: 9 additions & 0 deletions templates/generator/plugin_test_bootstrap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* This is the test bootstrap which you can use for overwriting
*/
use Origin\Core\Config;

require dirname(__DIR__, 3) . '/config/bootstrap.php';

Config::write('App.url', 'http://localhost');
6 changes: 5 additions & 1 deletion tests/TestCase/Console/Command/GenerateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,16 @@ public function testPlugin()

$filename = PLUGINS . DS . 'dummy' . DS . 'phpunit.xml';
$this->assertFileExists($filename);
$this->assertFileHash('547d46441f0876bac9d21742def30bc4', $filename);
$this->assertFileHash('6682a8306b3fb59117088aedf618b808', $filename);

$filename = PLUGINS . DS . 'dummy' . DS . 'composer.json';
$this->assertFileExists($filename);
$this->assertFileHash('5efb8dd1e0de11ce659e00bdf657b462', $filename);

$filename = PLUGINS . DS . 'dummy' . DS . 'tests/bootstrap.php';
$this->assertFileExists($filename);
$this->assertFileHash('a6cdc8b185d91fd6b6ac25058e4c4508', $filename);

$this->recursiveDelete(PLUGINS . DS . 'dummy');
}

Expand Down

0 comments on commit efa85b2

Please sign in to comment.