Skip to content

Commit

Permalink
Merge branch 'main' into dgir-48
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant-bd authored Nov 20, 2023
2 parents ef4dd54 + 4242fab commit 8c384be
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 51 deletions.
56 changes: 7 additions & 49 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,12 @@
---
name: PHPUnit Tests
on:
workflow_call:
inputs:
composer_prereqs:
required: false
type: string
composer_patches:
required: false
type: string
pull_request:
branches:
- main
workflow_dispatch:

jobs:
PHPUnit:
runs-on: ubuntu-latest
strategy:
matrix:
drupal-version: ['9.4']
php-version: ['7.4', '8.0']
experimental: [false]
include:
- drupal-version: '9'
php-version: '7.4'
experimental: true
- drupal-version: '9'
php-version: '8.1'
experimental: true
- drupal-version: '9.4'
php-version: '8.1'
experimental: true
continue-on-error: ${{ matrix.experimental }}
container:
image: drupal:${{ matrix.drupal-version }}-php${{ matrix.php-version }}
ports:
- 80
services:
postgres:
image: postgres
env:
POSTGRES_DB: drupal
POSTGRES_USER: drupal
POSTGRES_PASSWORD: drupal
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Run PHPUnit Action
uses: discoverygarden/phpunit-action@v1
with:
composer_package_prerequisites: ${{ inputs.composer_prereqs }}
composer_patches: ${{ inputs.composer_patches }}
composer-auth: ${{ secrets.PRIVATE_PACKAGIST_AUTH_ACCESS }}
uses: discoverygarden/phpunit-action/.github/workflows/phpunit.yml@v1
secrets: inherit
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# islandora_entity_status
# Islandora Entity Status
## Introduction

Cascades entity status to all referenced entities in an Islandora repository item

## Requirements

This module requires the following modules/libraries:

* [Islandora](https://github.com/Islandora/islandora)

## Installation

Install as usual, see
[this]( https://www.drupal.org/docs/extending-drupal/installing-modules) for
further information.

## Troubleshooting/Issues

Having problems or solved a problem? Contact [discoverygarden](http://support.discoverygarden.ca).

## Maintainers/Sponsors

This project has been sponsored by:

* [discoverygarden](http://wwww.discoverygarden.ca)

## Development

If you would like to contribute to this module, please check out our helpful
[Documentation for Developers](https://github.com/Islandora/islandora/wiki#wiki-documentation-for-developers)
info, [Developers](http://islandora.ca/developers) section on Islandora.ca and
contact [discoverygarden](http://support.discoverygarden.ca).

## License

[GPLv3](http://www.gnu.org/licenses/gpl-3.0.txt)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"require-dev": {
"discoverygarden/islandora_test_support": "^1"
}
}
}
40 changes: 40 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="/var/www/html/web/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
failOnWarning="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
cacheResult="false">
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
<env name="SIMPLETEST_BASE_URL" value="http://localhost"/>
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
<env name="SIMPLETEST_DB" value="pgsql://db:db@db:5432/db"/>
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
<!-- To have browsertest output use an alternative base URL. For example if
SIMPLETEST_BASE_URL is an internal DDEV URL, you can set this to the
external DDev URL so you can follow the links directly.
-->
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
<!-- To disable deprecation testing completely uncomment the next line. -->
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->
<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
<env name="MINK_DRIVER_CLASS" value=''/>
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS" value=''/>
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
</php>
<testsuites>
<testsuite name="islandora_entity_status">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
62 changes: 62 additions & 0 deletions tests/src/Kernel/IslandoraEntityStatusTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Drupal\Tests\islandora_entity_status\Kernel;

use Drupal\node\NodeInterface;
use Drupal\Tests\islandora_test_support\Kernel\AbstractIslandoraKernelTestBase;

/**
* Test Islandora Entity status.
*
* @group islandora_entity_status
*/
class IslandoraEntityStatusTest extends AbstractIslandoraKernelTestBase {

/**
* Modules to install.
*
* @var array
*/
protected static $modules = ['islandora_entity_status'];

/**
* Test that derivatives created on an unpublished node are unpublished.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testDerivativeUnpublishedStatus() {
// Create node.
$node = $this->createNode();

// Set node status as unpublished.
$node->setUnpublished();
$node->save();

// Create derivative.
$unpublishedDerivative = $this->createMedia($this->createFile(), $node);

// Test derivative status. It should be unpublished.
$this->assertSame(NodeInterface::NOT_PUBLISHED, intval($unpublishedDerivative->status->value));
}

/**
* Test that derivatives created on a published node are published.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testDerivativePublishedStatus() {
// Create node.
$node = $this->createNode();

// Set node status as published.
$node->setPublished();
$node->save();

// Create new derivative.
$publishedDerivative = $this->createMedia($this->createFile(), $node);

// Check derivative status. It should be published.
$this->assertSame(NodeInterface::PUBLISHED, intval($publishedDerivative->status->value));
}

}

0 comments on commit 8c384be

Please sign in to comment.