Skip to content

Commit

Permalink
LDP-606: Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Petar authored and fago committed Jan 5, 2021
1 parent 905208f commit 4c13946
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 24 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"require-dev": {
"phpunit/phpunit": "^9.5.0",
"drupal/pathauto": "^1.6",
"drupal/coder": "^8.2"
"drupal/coder": "^8.2",
"phpspec/prophecy-phpunit": "^2.0"
},
"repositories": {
"0": {
Expand Down
10 changes: 5 additions & 5 deletions src/Core/Path/AliasManagerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace drunomics\ServiceUtils\Core\Path;

use Drupal\Core\Path\AliasManagerInterface;
use Drupal\path_alias\AliasManagerInterface;

/**
* Allows setter injection and simple usage of the service.
Expand All @@ -12,14 +12,14 @@ trait AliasManagerTrait {
/**
* The alias manager.
*
* @var \Drupal\Core\Path\AliasManagerInterface
* @var \Drupal\path_alias\AliasManagerInterface
*/
protected $aliasManager;

/**
* Sets the entity type.
*
* @param \Drupal\Core\Path\AliasManagerInterface $aliasManager
* @param \Drupal\path_alias\AliasManagerInterface $aliasManager
* The alias manager.
*
* @return $this
Expand All @@ -32,12 +32,12 @@ public function setAliasManager(AliasManagerInterface $aliasManager) {
/**
* Gets the entity repository.
*
* @return \Drupal\Core\Path\AliasManagerInterface
* @return \Drupal\path_alias\AliasManagerInterface
* The alias manager.
*/
public function getAliasManager() {
if (empty($this->aliasManager)) {
$this->aliasManager = \Drupal::service('path.alias_manager');
$this->aliasManager = \Drupal::service('path_alias.manager');
}
return $this->aliasManager;
}
Expand Down
2 changes: 1 addition & 1 deletion src/user/SharedTempStoreFactoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace drunomics\ServiceUtils\user;

use Drupal\user\SharedTempStoreFactory;
use Drupal\Core\TempStore\SharedTempStoreFactory;

/**
* Allows setter injection and simple usage of the service.
Expand Down
2 changes: 2 additions & 0 deletions tests/src/Core/Config/ConfigFactoryTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use drunomics\ServiceUtils\Core\Config\ConfigFactoryTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Config\ConfigFactoryInterface;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Config\ConfigFactoryTrait
Expand All @@ -14,6 +15,7 @@
class ConfigFactoryTraitTest extends TestCase {

use ConfigFactoryTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/Entity/EntityRepositoryTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\Entity\EntityTypeManagerTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Entity\EntityTypeManagerTrait
* @group ServiceUtils
*/
class EntityRepositoryTraitTest extends \PHPUnit_Framework_TestCase {
class EntityRepositoryTraitTest extends TestCase {

use EntityTypeManagerTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/Entity/EntityTypeManagerTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\Entity\EntityRepositoryTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Entity\EntityRepositoryInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Entity\EntityRepositoryTrait
* @group ServiceUtils
*/
class EntityTypeManagerTraitTest extends \PHPUnit_Framework_TestCase {
class EntityTypeManagerTraitTest extends TestCase {

use EntityRepositoryTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/File/FileSystemTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\File\FileSystemTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\File\FileSystemInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\File\FileSystemTrait
* @group ServiceUtils
*/
class FileSystemTraitTest extends \PHPUnit_Framework_TestCase {
class FileSystemTraitTest extends TestCase {

use FileSystemTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
11 changes: 7 additions & 4 deletions tests/src/Core/Path/AliasManagerTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@

use drunomics\ServiceUtils\Core\Path\AliasManagerTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\path_alias\AliasManagerInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Path\AliasManagerTrait
* @group ServiceUtils
*/
class AliasManagerTraitTest extends \PHPUnit_Framework_TestCase {
class AliasManagerTraitTest extends TestCase {

use AliasManagerTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
*
* @var string
*/
protected $serviceId = 'path.alias_manager';
protected $serviceId = 'path_alias.manager';

/**
* @covers ::getAliasManager
Expand All @@ -36,7 +39,7 @@ public function testGetter() {
* @covers ::setAliasManager
*/
public function testSetter() {
// Verify the set service is returned.
// Verify the set service is returned.
$this->mockContainerWithFakeService(['calls' => 0]);
$service = $this->prophesize()
->willImplement(AliasManagerInterface::class)
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/Plugin/BlockManagerTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\Plugin\BlockManagerTrait;
use Drupal\Core\Block\BlockManagerInterface;
use Drupal\Core\DependencyInjection\Container;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Entity\EntityTypeManagerTrait
* @group ServiceUtils
*/
class BlockManagerTraitTest extends \PHPUnit_Framework_TestCase {
class BlockManagerTraitTest extends TestCase {

use BlockManagerTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/Render/MainContent/AjaxRendererTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\Render\MainContent\AjaxRendererTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Render\MainContent\MainContentRendererInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Render\MainContent\AjaxRendererTrait
* @group ServiceUtils
*/
class AjaxRendererTraitTest extends \PHPUnit_Framework_TestCase {
class AjaxRendererTraitTest extends TestCase {

use AjaxRendererTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/Render/RendererTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\Render\RendererTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Render\RendererInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Render\RendererTrait
* @group ServiceUtils
*/
class RendererTraitTest extends \PHPUnit_Framework_TestCase {
class RendererTraitTest extends TestCase {

use RendererTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/Session/CurrentUserTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\Session\CurrentUserTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Session\AccountProxyInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\Session\CurrentUserTrait
* @group ServiceUtils
*/
class CurrentUserTraitTest extends \PHPUnit_Framework_TestCase {
class CurrentUserTraitTest extends TestCase {

use CurrentUserTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Core/State/StateTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\Core\State\StateTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\State\StateInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Core\State\StateTrait
* @group ServiceUtils
*/
class StateTraitTest extends \PHPUnit_Framework_TestCase {
class StateTraitTest extends TestCase {

use StateTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Symfony/HttpFoundation/RequestStackTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

use drunomics\ServiceUtils\Symfony\HttpFoundation\RequestStackTrait;
use Drupal\Core\DependencyInjection\Container;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\HttpFoundation\RequestStack;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass \drunomics\ServiceUtils\Symfony\HttpFoundation\RequestStackTrait
* @group ServiceUtils
*/
class RequestStackTraitTest extends \PHPUnit_Framework_TestCase {
class RequestStackTraitTest extends TestCase {

use RequestStackTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/file/FileUsage/FileUsageTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\file\FileUsage\FileUsageTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\file\FileUsage\FileUsageInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\file\FileUsage\FileUsageTrait
* @group ServiceUtils
*/
class FileUsageTraitTest extends \PHPUnit_Framework_TestCase {
class FileUsageTraitTest extends TestCase {

use FileUsageTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
5 changes: 4 additions & 1 deletion tests/src/pathauto/PathautoGeneratorTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use drunomics\ServiceUtils\pathauto\PathautoGeneratorTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\pathauto\PathautoGeneratorInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\pathauto\PathautoGeneratorTrait
* @group ServiceUtils
*/
class PathautoGeneratorTraitTest extends \PHPUnit_Framework_TestCase {
class PathautoGeneratorTraitTest extends TestCase {

use PathautoGeneratorTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down
7 changes: 5 additions & 2 deletions tests/src/user/SharedTempStoreFactoryTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

use drunomics\ServiceUtils\user\SharedTempStoreFactoryTrait;
use Drupal\Core\DependencyInjection\Container;
use Drupal\user\SharedTempStoreFactory;
use Drupal\Core\TempStore\SharedTempStoreFactory;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @coversDefaultClass \drunomics\ServiceUtils\user\SharedTempStoreFactoryTrait
* @group ServiceUtils
*/
class SharedTempStoreFactoryTraitTest extends \PHPUnit_Framework_TestCase {
class SharedTempStoreFactoryTraitTest extends TestCase {

use SharedTempStoreFactoryTrait;
use ProphecyTrait;

/**
* The id of the trait's service.
Expand Down

0 comments on commit 4c13946

Please sign in to comment.