Skip to content

Commit

Permalink
Merge pull request #20 from antistatique/1.0.x--ci-update
Browse files Browse the repository at this point in the history
  • Loading branch information
WengerK authored Aug 12, 2022
2 parents b0cf346 + aa45c7b commit 978cac6
Show file tree
Hide file tree
Showing 47 changed files with 136 additions and 61 deletions.
1 change: 0 additions & 1 deletion .chanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"release-prefix": ""
}

41 changes: 36 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:

strategy:
matrix:
drupal_version: ['8.8', '8.9', '9.0']
drupal_version: ['9.1', '9.2', '9.3', '9.4', '9.5']
module: ['factory_lollipop']
experimental: [ false ]
include:
- drupal_version: '9.1'
- drupal_version: '9.5'
module: 'factory_lollipop'
experimental: true

Expand All @@ -32,7 +32,7 @@ jobs:
- name: wait on Docker to be ready, especially MariaDB that takes many seconds to be up
run: docker-compose exec -T drupal wait-for-it db:3306 -t 60
- name: Run unit tests
run: docker-compose -f docker-compose.yml run -u www-data drupal phpunit --no-coverage --group=${{ matrix.module }} --exclude-group=${{ matrix.module }}_functional --configuration=/var/www/html/phpunit.xml
run: docker-compose -f docker-compose.yml exec -T -u www-data drupal phpunit --no-coverage --group=${{ matrix.module }} --exclude-group=${{ matrix.module }}_functional --configuration=/var/www/html/phpunit.xml
continue-on-error: ${{ matrix.experimental }}

tests-functional:
Expand All @@ -42,11 +42,11 @@ jobs:

strategy:
matrix:
drupal_version: [ '8.8', '8.9', '9.0' ]
drupal_version: ['9.1', '9.2', '9.3', '9.4', '9.5']
module: [ 'factory_lollipop' ]
experimental: [ false ]
include:
- drupal_version: '9.1'
- drupal_version: '9.5'
module: 'factory_lollipop'
experimental: true

Expand All @@ -67,3 +67,34 @@ jobs:
- name: Run tests
run: docker-compose -f docker-compose.yml exec -T -u www-data drupal phpunit --no-coverage --group=${{ matrix.module }}_functional --configuration=/var/www/html/phpunit.xml
continue-on-error: ${{ matrix.experimental }}

upgrade-status:
name: Upgrade Status
runs-on: ubuntu-latest

strategy:
matrix:
drupal_version: ['9.4']
module: ['factory_lollipop']

steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- run: docker-compose -f docker-compose.yml pull --include-deps drupal
- name: Build the docker-compose stack
run: docker-compose -f docker-compose.yml build --pull --build-arg BASE_IMAGE_TAG=${{ matrix.drupal_version }} drupal
- name: Up a persistent Docker Container
run: docker-compose -f docker-compose.yml up -d drupal
- name: Add upgrade status dependency
run: docker-compose exec -T drupal wait-for-it db:3306 -- composer require --dev drupal/upgrade_status --no-interaction
- name: Bootstrap Drupal
run: docker-compose -f docker-compose.yml exec -T -u www-data drupal drush site-install standard --db-url="mysql://drupal:drupal@db/drupal" -y
- name: Enable upgrade status
run: docker-compose exec -T drupal wait-for-it db:3306 -- ./vendor/bin/drush en upgrade_status -y
- name: Disable incompatible module
run: docker-compose exec -T drupal wait-for-it db:3306 -- ./vendor/bin/drush pmu page_cache -y
- name: Enable the module
run: docker-compose exec -T drupal wait-for-it db:3306 -- ./vendor/bin/drush en ${{ matrix.module }} -y
- name: Run upgrade status
run: docker-compose exec -T drupal wait-for-it db:3306 -- ./vendor/bin/drush upgrade_status:analyze ${{ matrix.module }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- add support Drupal 9.4 & 9.5

### Changed
- drop support of Drupal 8
- drop support of Drupal 9.0 (keep 9.1+)
- fix D9.3 test failures - "Role label is expected to be a string."
- use the durpal 9.1 service password_generator instead of deprecated user_password()

## [Unreleased]
## 1.0.0 - 2022-08-12
### Added
- init module
Expand Down
11 changes: 10 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Developing on Factory Lollipop

* Issues should be filed at
https://www.drupal.org/project/issues/factory_lollipop
* Pull requests can be made against
https://github.com/antistatique/drupal-factory-lollipop/pulls

## 📦 Repositories

Drupal repo

```bash
git remote add drupal \
[email protected]:project/factory_lollipop.git
```

Github repo

```bash
Expand All @@ -26,7 +35,7 @@ on your environment:

Once run, you will be able to access to your fresh installed Drupal on `localhost::8888`.

docker-compose build --pull --build-arg BASE_IMAGE_TAG=8.9 drupal
docker-compose build --pull --build-arg BASE_IMAGE_TAG=9.1 drupal
# (get a coffee, this will take some time...)
docker-compose up -d drupal
docker-compose exec -u www-data drupal drush site-install standard --db-url="mysql://drupal:drupal@db/drupal" -y
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE_TAG=8.9
ARG BASE_IMAGE_TAG=9.1
FROM wengerk/drupal-for-contrib:${BASE_IMAGE_TAG}

ARG BASE_IMAGE_TAG
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ It may be useful for existing users to check out the [upgrade guide](UPGRADING.m

## Versions

Factory Lollipop is available for both Drupal 8 and Drupal 9!
Factory Lollipop is available for both Drupal 9 and Drupal 10!

### Which version should I use?

|Drupal Core|Factory Lollipop|
|:---------:|:--------------:|
|8.8.x |1.0.x |
|9.x |1.0.x |
| Drupal Core | Factory Lollipop |
|:-----------:|:----------------:|
| 8.x | 1.0.0 |
| 9.0 | 1.0.0 |
| 9.x | 1.1.x |
| 10.x | 1.1.x |

## Roadmap

Expand All @@ -97,7 +99,7 @@ _Everything contained before is in draft form and subject to change. We do not g

## Dependencies

The Drupal 8 and Drupal 9 version of Factory Lollipop requires nothing !
The Drupal 9 version of Factory Lollipop requires nothing !
Feel free to use it.

Factory Lollipop requires PHP 7.3+ to works properly. We recommend updating to at least PHP 7.4 if possible, which is supported as of Drupal 8.8.3 (release date: March 7, 2018).
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
volumes:
# Mount the module Factory Lollipop in the proper contrib module directory.
- .:/var/www/html/modules/contrib/factory_lollipop
restart: always
restart: unless-stopped

db:
image: mariadb:10.3.7
Expand All @@ -20,4 +20,4 @@ services:
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal
MYSQL_ROOT_PASSWORD: root
restart: always
restart: unless-stopped
4 changes: 3 additions & 1 deletion factory_lollipop.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ name: Factory Lollipop
description: 'Factory Lollipop is a comprehensive solution for using the factory pattern to generate short-lived test data-structure.'
package: 'Development'
type: module
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^9.1 || ^10
dependencies:
- drupal:user
1 change: 1 addition & 0 deletions factory_lollipop.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ services:
- { name: factory_lollipop.factory_type_resolver, priority: 220 }
calls:
- [setEntityTypeManager, ['@entity_type.manager']]
- [setPasswordGenerator, ['@password_generator']]

factory_lollipop.factory_type.menu:
class: Drupal\factory_lollipop\FactoryType\MenuFactoryType
Expand Down
22 changes: 21 additions & 1 deletion src/FactoryType/UserFactoryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\factory_lollipop\Traits\RandomGeneratorTrait;
use Drupal\factory_lollipop\Traits\UserCreationTrait;
use Drupal\user\UserInterface;
use Drupal\Core\Password\PasswordGeneratorInterface;

/**
* Creates Drupal Users for use in tests.
Expand All @@ -21,6 +22,13 @@ class UserFactoryType implements FactoryTypeInterface {
*/
protected $entityTypeManager;

/**
* Generating passwords.
*
* @var \Drupal\Core\Password\PasswordGeneratorInterface|null
*/
protected $passwordGenerator;

/**
* Sets the entity type manager.
*
Expand All @@ -33,6 +41,18 @@ public function setEntityTypeManager(EntityTypeManagerInterface $entity_type_man
$this->entityTypeManager = $entity_type_manager;
}

/**
* Sets the password generator.
*
* This is only called when the factory is instantiated.
*
* @param \Drupal\Core\Password\PasswordGeneratorInterface $password_generator
* The new password generator.
*/
public function setPasswordGenerator(PasswordGeneratorInterface $password_generator): void {
$this->passwordGenerator = $password_generator;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -70,7 +90,7 @@ public function create(?object $attributes = NULL): UserInterface {
$mail = $attributes['mail'] ?? $name . '@example.com';
$roles = $attributes['roles'] ?? [];
$status = $attributes['status'] ?? 1;
$pass = $attributes['pass'] ?? user_password();
$pass = $attributes['pass'] ?? $this->passwordGenerator->generate();

// Prevent creation of already existing User.
if ($uid) {
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/UserCreationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function createUser(array $permissions = [], $name = NULL, $admin = FA
}
$edit += [
'mail' => $edit['name'] . '@example.com',
'pass' => user_password(),
'pass' => \Drupal::service('password_generator')->generate(),
'status' => 1,
];
if ($rid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Factory Lollipop Test
type: module
description: Contains various example of Factory Lollipop usage.
package: Testing
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^9

dependencies:
- factory_lollipop:factory_lollipop
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FileFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'file',
'factory_lollipop_test',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FixtureFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'node',
'taxonomy',
'file',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MediaFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'media',
'file',
'image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MediaFieldEntityReferenceFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'media',
'file',
'image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MediaFieldFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'media',
'file',
'image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MediaTypeFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'media',
'file',
'image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MenuFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'factory_lollipop_test',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MenuLinkFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'link',
'menu_link_content',
'factory_lollipop_test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MenuLinksFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'link',
'menu_link_content',
'factory_lollipop_test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NodeFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'node',
'factory_lollipop_test',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class NodeFieldEntityReferenceFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'node',
'factory_lollipop_test',
];

/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();

// Create an entity test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NodeFieldFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'node',
'factory_lollipop_test',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class NodeTypeFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'node',
'factory_lollipop_test',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RoleFactoryTest extends LollipopKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
protected static $modules = [
'user',
'factory_lollipop_test',
];
Expand Down
Loading

0 comments on commit 978cac6

Please sign in to comment.