Skip to content

Commit

Permalink
fix test autoloading namespace paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed May 7, 2024
1 parent 254bc3b commit 55d3571
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 43 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"psr/log": "^1 || ^2 || ^3",
"phpcr/phpcr-api-tests": "2.1.25",
"phpunit/phpunit": "^9.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"symfony/cache": "^5.4 || ^6.2 || ^7.0",
"phpstan/phpstan": "^1.10"
},
Expand All @@ -44,8 +43,10 @@
"psr-0": { "Jackalope\\": "src/" }
},
"autoload-dev": {
"psr-4": {
"Jackalope\\Tests\\": "tests/"
},
"psr-0": {
"Jackalope\\Test\\": "tests/",
"Jackalope\\": "vendor/jackalope/jackalope/tests",
"PHPCR": "vendor/phpcr/phpcr/tests"
}
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

<testsuites>
<testsuite name="Jackalope Doctrine DBAL Tests">
<directory>tests/Jackalope/Transport</directory>
<directory>tests/Jackalope/Tools</directory>
<directory>tests/Transport</directory>
<directory>tests/Tools</directory>
<directory>vendor/jackalope/jackalope/tests</directory>
<directory>vendor/phpcr/phpcr/tests</directory>
<directory>vendor/phpcr/phpcr-utils/tests</directory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test;
namespace Jackalope\Tests;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\SqlitePlatform;
Expand All @@ -10,6 +10,7 @@
use Jackalope\Transport\DoctrineDBAL\Client;
use Jackalope\Transport\DoctrineDBAL\RepositorySchema;
use Jackalope\Transport\TransportInterface;
use Jackalope\Transport\WorkspaceManagementInterface;
use PHPCR\RepositoryException;
use PHPCR\SimpleCredentials;

Expand All @@ -29,6 +30,7 @@ public function setUp(): void
$conn = $this->getConnection();
$this->loadFixtures($conn);
$this->transport = $this->getClient($conn);
$this->assertInstanceOf(WorkspaceManagementInterface::class, $this->transport);

$this->transport->createWorkspace('default');
$this->repository = new Repository(null, $this->transport);
Expand Down
8 changes: 4 additions & 4 deletions tests/ImplementationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Jackalope\Repository;
use Jackalope\RepositoryFactoryDoctrineDBAL;
use Jackalope\Session;
use Jackalope\Test\Tester\Generic;
use Jackalope\Test\Tester\Mysql;
use Jackalope\Test\Tester\Pgsql;
use Jackalope\Tests\Test\Tester\Generic;
use Jackalope\Tests\Test\Tester\Mysql;
use Jackalope\Tests\Test\Tester\Pgsql;
use Jackalope\Transport\DoctrineDBAL\Client;
use Jackalope\Transport\Logging\Psr3Logger;
use PHPCR\RepositoryException;
Expand Down Expand Up @@ -141,8 +141,8 @@ public function getRepositoryFactoryParameters()

public function getSessionWithLastModified()
{
/** @var $session Session */
$session = $this->getSession();
\assert($session instanceof Session);
$session->setSessionOption(Session::OPTION_AUTO_LASTMODIFIED, true);

return $session;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Jackalope;
namespace Jackalope\Tests;

use Doctrine\DBAL\Connection;
use Jackalope\RepositoryFactoryDoctrineDBAL;
use PHPCR\ConfigurationException;
use PHPUnit\Framework\TestCase;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test\Fixture;
namespace Jackalope\Tests\Test\Fixture;

use PHPCR\Util\PathHelper;
use PHPCR\Util\UUIDHelper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test\Fixture;
namespace Jackalope\Tests\Test\Fixture;

/**
* Jackalope Document or System Views.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test\Fixture;
namespace Jackalope\Tests\Test\Fixture;

/**
* Base for Jackalope Document or System Views and PHPUnit DBUnit Fixture XML classes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test\Tester;
namespace Jackalope\Tests\Test\Tester;

use Doctrine\DBAL\Connection;
use PHPCR\Test\FixtureLoaderInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test\Tester;
namespace Jackalope\Tests\Test\Tester;

/**
* MySQL specific tester class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test\Tester;
namespace Jackalope\Tests\Test\Tester;

/**
* PostgreSQL specific tester class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Jackalope\Test\Tester;
namespace Jackalope\Tests\Test\Tester;

use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Index;
Expand Down
2 changes: 1 addition & 1 deletion tests/Jackalope/Test/TestCase.php → tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Test;
namespace Jackalope\Tests;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Tools\Console;
namespace Jackalope\Tests\Tools\Console;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
Expand All @@ -9,6 +9,7 @@
use Doctrine\DBAL\Schema\SchemaConfig;
use Jackalope\Tools\Console\Command\InitDoctrineDbalCommand;
use Jackalope\Tools\Console\Helper\DoctrineDbalHelper;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
Expand All @@ -22,7 +23,7 @@ class InitDoctrineDbalCommandTest extends TestCase
protected $helperSet;

/**
* @var Connection
* @var Connection&MockObject
*/
protected $connection;

Expand All @@ -32,7 +33,7 @@ class InitDoctrineDbalCommandTest extends TestCase
protected $platform;

/**
* @var AbstractSchemaManager
* @var AbstractSchemaManager&MockObject
*/
protected $schemaManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL;
namespace Jackalope\Tests\Transport\DoctrineDBAL;

use Doctrine\DBAL\Connection;
use Jackalope\Factory;
use Jackalope\Transport\DoctrineDBAL\CachedClient;
use Jackalope\Transport\TransportInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Psr16Cache;

class CachedClientFunctionalTest extends ClientTest
{
protected function getClient(Connection $conn)
protected function getClient(Connection $conn): TransportInterface
{
$nodeCacheAdapter = new ArrayAdapter();
$nodeCache = new Psr16Cache($nodeCacheAdapter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL;
namespace Jackalope\Tests\Transport\DoctrineDBAL;

use Doctrine\DBAL\Connection;
use Jackalope\Factory;
use Jackalope\Test\FunctionalTestCase;
use Jackalope\Tests\FunctionalTestCase;
use Jackalope\Transport\DoctrineDBAL\CachedClient;
use Jackalope\Transport\TransportInterface;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
Expand All @@ -30,7 +31,7 @@ public function testArrayObjectIsConvertedToArray(): void
self::assertIsArray($namespaces);
}

public function testCacheHit()
public function testCacheHit(): void
{
$cache = new \stdClass();
$cache->foo = 'bar';
Expand All @@ -39,7 +40,7 @@ public function testCacheHit()
}

/**
* The default key sanitizer keeps the cache key compatible with PSR16
* The default key sanitizer keeps the cache key compatible with PSR16.
*/
public function testDefaultKeySanitizer(): void
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL;
namespace Jackalope\Tests\Transport\DoctrineDBAL;

use Doctrine\DBAL\Platforms\MySQLPlatform;
use Jackalope\Test\FunctionalTestCase;
use Jackalope\Tests\FunctionalTestCase;
use Jackalope\Transport\DoctrineDBAL\Client;
use Jackalope\Transport\WritingInterface;
use PHPCR\PropertyType;
use PHPCR\Query\QOM\QueryObjectModelConstantsInterface;
use PHPCR\Query\QueryInterface;
Expand Down Expand Up @@ -157,6 +159,7 @@ public function testDepthOnMove(): void
$topic3->addNode('page3');
$this->session->save();

$this->assertInstanceOf(WritingInterface::class, $this->transport);
$this->transport->moveNodeImmediately('/topic2/page2', '/topic1/page1/page2');

$this->transport->moveNodeImmediately('/topic3', '/topic1/page1/page2/topic3');
Expand Down Expand Up @@ -323,7 +326,7 @@ public function testPropertyLengthAttribute(): void

$values = $xpath->query('sv:value', $propertyElement->item(0));

/** @var $value \DOMElement */
/** @var \DOMElement $value */
foreach ($values as $index => $value) {
$lengthAttribute = $value->attributes->getNamedItem('length');
if (null === $lengthAttribute) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL;
namespace Jackalope\Tests\Transport\DoctrineDBAL;

use Doctrine\DBAL\Platforms\SqlitePlatform;
use Jackalope\Test\FunctionalTestCase;
use Jackalope\Tests\FunctionalTestCase;
use PHPCR\PropertyType;

class DeleteCascadeTest extends FunctionalTestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL;
namespace Jackalope\Tests\Transport\DoctrineDBAL;

use Jackalope\Test\FunctionalTestCase;
use Jackalope\Tests\FunctionalTestCase;

class PrefetchTest extends FunctionalTestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL\Query;
namespace Jackalope\Tests\Transport\DoctrineDBAL\Query;

use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
Expand All @@ -10,10 +10,12 @@
use Jackalope\Query\QOM\PropertyValue;
use Jackalope\Query\QOM\QueryObjectModel;
use Jackalope\Query\QOM\QueryObjectModelFactory;
use Jackalope\Test\TestCase;
use Jackalope\Tests\TestCase;
use Jackalope\Transport\DoctrineDBAL\Query\QOMWalker;
use PHPCR\NodeType\NodeTypeManagerInterface;
use PHPCR\Query\InvalidQueryException;
use PHPCR\Query\QOM\QueryObjectModelConstantsInterface;
use PHPUnit\Framework\MockObject\MockObject;

class QOMWalkerTest extends TestCase
{
Expand All @@ -28,7 +30,7 @@ class QOMWalkerTest extends TestCase
private $walker;

/**
* @var NodeTypeManagerInterface
* @var NodeTypeManagerInterface&MockObject
*/
private $nodeTypeManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL\XmlParser;
namespace Jackalope\Tests\Transport\DoctrineDBAL\XmlParser;

use Jackalope\Factory;
use Jackalope\Test\TestCase;
use Jackalope\Tests\TestCase;
use Jackalope\Transport\DoctrineDBAL\XmlParser\XmlToPropsParser;
use PHPCR\Util\ValueConverter;

class XmlToPropsParserTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Jackalope\Transport\DoctrineDBAL\XmlPropsRemover;
namespace Jackalope\Tests\Transport\DoctrineDBAL\XmlPropsRemover;

use Jackalope\Factory;
use Jackalope\Test\TestCase;
use Jackalope\Tests\TestCase;
use Jackalope\Transport\DoctrineDBAL\XmlParser\XmlToPropsParser;
use Jackalope\Transport\DoctrineDBAL\XmlPropsRemover\XmlPropsRemover;
use PHPCR\Util\ValueConverter;

class XmlPropsRemoverTest extends TestCase
Expand Down
4 changes: 2 additions & 2 deletions tests/generate_fixtures.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Jackalope\Test\Fixture\DBUnitFixtureXML;
use Jackalope\Test\Fixture\JCRSystemXML;
use Jackalope\Tests\Test\Fixture\DBUnitFixtureXML;
use Jackalope\Tests\Test\Fixture\JCRSystemXML;

/**
* Convert Jackalope Document or System Views into PHPUnit DBUnit Fixture XML files.
Expand Down

0 comments on commit 55d3571

Please sign in to comment.