Skip to content

Commit

Permalink
Merge pull request #633 from TomHAnderson/feature/test-case
Browse files Browse the repository at this point in the history
Feature/test case
  • Loading branch information
TomHAnderson authored Oct 28, 2024
2 parents e08ddff + 9876f90 commit 18d03cb
Show file tree
Hide file tree
Showing 42 changed files with 244 additions and 100 deletions.
31 changes: 31 additions & 0 deletions tests/Assets/Serializers/ArrayableEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Serializers;

use LaravelDoctrine\ORM\Serializers\Arrayable;

class ArrayableEntity
{
use Arrayable;

protected $id = 'IDVALUE';

protected $name = 'NAMEVALUE';

protected $list = ['item1', 'item2'];

public function getId()
{
return $this->id;
}

public function getName()
{
return $this->name;
}

public function getList()
{
return $this->list;
}
}
31 changes: 31 additions & 0 deletions tests/Assets/Serializers/JsonableEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Serializers;

use LaravelDoctrine\ORM\Serializers\Jsonable;

class JsonableEntity
{
use Jsonable;

protected $id = 'IDVALUE';

protected $name = 'NAMEVALUE';

protected $numeric = "1";

public function getId()
{
return $this->id;
}

public function getName()
{
return $this->name;
}

public function getNumeric()
{
return $this->numeric;
}
}
6 changes: 5 additions & 1 deletion tests/Feature/Auth/DoctrineUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use LaravelDoctrine\ORM\Auth\DoctrineUserProvider;
use LaravelDoctrineTest\ORM\Assets\Auth\AuthenticableMock;
use LaravelDoctrineTest\ORM\Assets\Auth\AuthenticableWithNonEmptyConstructorMock;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use Mockery\Mock;
use PHPUnit\Framework\TestCase;

class DoctrineUserProviderTest extends TestCase
{
Expand Down Expand Up @@ -55,6 +55,8 @@ protected function setUp(): void
$this->em,
AuthenticableWithNonEmptyConstructorMock::class
);

parent::setUp();
}

public function test_can_retrieve_by_id()
Expand Down Expand Up @@ -189,5 +191,7 @@ protected function mockGetRepository($class = AuthenticableMock::class)
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
6 changes: 5 additions & 1 deletion tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Illuminate\Contracts\Hashing\Hasher;
use LaravelDoctrine\ORM\Auth\Passwords\DoctrineTokenRepository;
use LaravelDoctrineTest\ORM\Assets\Auth\Passwords\UserMock;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use Mockery\Mock;
use PHPUnit\Framework\TestCase;

class DoctrineTokenRepositoryTest extends TestCase
{
Expand Down Expand Up @@ -66,6 +66,8 @@ protected function setUp(): void
'hashkey',
60
);

parent::setUp();
}

public function test_can_create_a_token()
Expand Down Expand Up @@ -274,5 +276,7 @@ public function test_can_delete_expired()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace LaravelDoctrineTest\ORM\Feature\Configuration\Cache;

use LaravelDoctrineTest\ORM\TestCase;
use Mockery;
use PHPUnit\Framework\TestCase;

abstract class AbstractCacheProviderTest extends TestCase
{
Expand All @@ -19,5 +19,7 @@ public function test_can_resolve()
public function tearDown(): void
{
Mockery::close();

parent::tearDown();
}
}
6 changes: 5 additions & 1 deletion tests/Feature/Configuration/Cache/CacheManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use LaravelDoctrine\ORM\Configuration\Cache\CacheManager;
use LaravelDoctrine\ORM\Configuration\Cache\FileCacheProvider;
use LaravelDoctrine\ORM\Exceptions\DriverNotFound;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

class CacheManagerTest extends TestCase
Expand Down Expand Up @@ -39,6 +39,8 @@ protected function setUp(): void
$this->manager = new CacheManager(
$this->app
);

parent::setUp();
}

public function test_driver_returns_the_default_driver()
Expand Down Expand Up @@ -98,5 +100,7 @@ public function test_can_replace_an_existing_driver()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Illuminate\Contracts\Cache\Factory;
use Illuminate\Contracts\Cache\Repository;
use LaravelDoctrine\ORM\Configuration\Cache\IlluminateCacheProvider;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use PHPUnit\Framework\TestCase;

class IlluminateCacheProviderTest extends TestCase
{
Expand All @@ -32,6 +32,8 @@ protected function setUp(): void
->andReturn($this->repository);

$this->driver = new IlluminateCacheProvider($manager);

parent::setUp();
}

public function test_driver_returns_provided_namespace(): void
Expand Down Expand Up @@ -61,5 +63,7 @@ public function test_driver_has_no_namespace_by_default(): void
public function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,3 @@ public function getExpectedInstance()
return PhpFilesAdapter::class;
}
}

if(!function_exists('storage_path')) {
function storage_path($path = null)
{
$storage = __DIR__ . DIRECTORY_SEPARATOR . '../../Stubs/storage';

return is_null($path) ? $storage : $storage . DIRECTORY_SEPARATOR . $path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use LaravelDoctrine\ORM\Configuration\Connections\MysqlConnection;
use LaravelDoctrine\ORM\Configuration\Connections\SqliteConnection;
use LaravelDoctrine\ORM\Exceptions\DriverNotFound;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use PHPUnit\Framework\TestCase;

class ConnectionManagerTest extends TestCase
{
Expand Down Expand Up @@ -39,6 +39,8 @@ protected function setUp(): void
$this->manager = new ConnectionManager(
$this->app
);

parent::setUp();
}

public function test_driver_returns_the_default_driver()
Expand Down Expand Up @@ -99,5 +101,7 @@ public function test_can_replace_an_existing_driver()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Connections\MysqlConnection;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use Mockery\Mock;
use PHPUnit\Framework\TestCase;

class MysqlConnectionTest extends TestCase
{
Expand All @@ -25,6 +25,8 @@ protected function setUp(): void
$this->config = m::mock(Repository::class);

$this->connection = new MysqlConnection($this->config);

parent::setUp();
}

public function test_can_resolve()
Expand Down Expand Up @@ -69,5 +71,7 @@ public function test_can_resolve()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Connections\OracleConnection;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use Mockery\Mock;
use PHPUnit\Framework\TestCase;

class OracleConnectionTest extends TestCase
{
Expand All @@ -25,6 +25,8 @@ protected function setUp(): void
$this->config = m::mock(Repository::class);

$this->connection = new OracleConnection($this->config);

parent::setUp();
}

public function test_can_resolve()
Expand Down Expand Up @@ -57,5 +59,7 @@ public function test_can_resolve()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Connections\PgsqlConnection;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use Mockery\Mock;
use PHPUnit\Framework\TestCase;

class PgsqlConnectionTest extends TestCase
{
Expand All @@ -25,6 +25,8 @@ protected function setUp(): void
$this->config = m::mock(Repository::class);

$this->connection = new PgsqlConnection($this->config);

parent::setUp();
}

public function test_can_resolve()
Expand Down Expand Up @@ -69,5 +71,7 @@ public function test_can_resolve()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection as PrimaryReadReplicaDoctrineWrapper;
use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Connections\PrimaryReadReplicaConnection;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use PHPUnit\Framework\TestCase;

/**
* Basic unit tests for primary read-replica connection
Expand All @@ -18,6 +18,8 @@ protected function setUp(): void
if (!class_exists(PrimaryReadReplicaDoctrineWrapper::class)) {
$this->markTestSkipped('Skipped for doctrine/dbal < 2.11');
}

parent::setUp();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Connections\SqliteConnection;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use Mockery\Mock;
use PHPUnit\Framework\TestCase;

class SqliteConnectionTest extends TestCase
{
Expand All @@ -25,6 +25,8 @@ protected function setUp(): void
$this->config = m::mock(Repository::class);

$this->connection = new SqliteConnection($this->config);

parent::setUp();
}

public function test_can_resolve()
Expand Down Expand Up @@ -80,5 +82,7 @@ public function test_can_resolve_with_full_in__memory_database()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Connections\SqlsrvConnection;
use LaravelDoctrineTest\ORM\TestCase;
use Mockery as m;
use Mockery\Mock;
use PHPUnit\Framework\TestCase;

class SqlsrvConnectionTest extends TestCase
{
Expand All @@ -25,6 +25,8 @@ protected function setUp(): void
$this->config = m::mock(Repository::class);

$this->connection = new SqlsrvConnection($this->config);

parent::setUp();
}

public function test_can_resolve()
Expand Down Expand Up @@ -57,5 +59,7 @@ public function test_can_resolve()
protected function tearDown(): void
{
m::close();

parent::tearDown();
}
}
2 changes: 1 addition & 1 deletion tests/Feature/Configuration/CustomTypeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use LaravelDoctrine\ORM\Configuration\CustomTypeManager;
use LaravelDoctrineTest\ORM\Assets\Configuration\TypeMock;
use LaravelDoctrineTest\ORM\Assets\Configuration\TypeMock2;
use PHPUnit\Framework\TestCase;
use LaravelDoctrineTest\ORM\TestCase;

class CustomTypeManagerTest extends TestCase
{
Expand Down
Loading

0 comments on commit 18d03cb

Please sign in to comment.