Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/test namespace #632

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpunit/phpunit": "^9.3"
"phpunit/phpunit": "^9.3",
"fakerphp/faker": "^1.23"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 7 additions & 0 deletions tests/Assets/AnotherListenerStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets;

class AnotherListenerStub
{
}
16 changes: 16 additions & 0 deletions tests/Assets/Auth/AuthenticableMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Auth;

use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use LaravelDoctrine\ORM\Auth\Authenticatable;

class AuthenticableMock implements AuthenticatableContract
{
use Authenticatable;

public function __construct()
{
$this->password = 'myPassword';
}
}
16 changes: 16 additions & 0 deletions tests/Assets/Auth/AuthenticableWithNonEmptyConstructorMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Auth;

use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use LaravelDoctrine\ORM\Auth\Authenticatable;

class AuthenticableWithNonEmptyConstructorMock implements AuthenticatableContract
{
use Authenticatable;

public function __construct(array $passwords)
{
$this->password = $passwords[0];
}
}
28 changes: 28 additions & 0 deletions tests/Assets/Auth/Passwords/UserMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Auth\Passwords;

use Illuminate\Contracts\Auth\CanResetPassword;

class UserMock implements CanResetPassword
{
/**
* Get the e-mail address where password reset links are sent.
* @return string
*/
public function getEmailForPasswordReset()
{
return '[email protected]';
}

/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
// TODO: Implement sendPasswordResetNotification() method.
}
}
18 changes: 18 additions & 0 deletions tests/Assets/Configuration/TypeMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Configuration;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;

class TypeMock extends Type
{
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return '';
}

public function getName()
{
}
}
18 changes: 18 additions & 0 deletions tests/Assets/Configuration/TypeMock2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Configuration;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;

class TypeMock2 extends Type
{
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return '';
}

public function getName()
{
}
}
9 changes: 9 additions & 0 deletions tests/Assets/Decorator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets;

use Doctrine\ORM\Decorator\EntityManagerDecorator;

class Decorator extends EntityManagerDecorator
{
}
10 changes: 10 additions & 0 deletions tests/Assets/Entity/Foo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Entity;

class Foo
{
private $id;

private $name;
}
25 changes: 25 additions & 0 deletions tests/Assets/Extensions/ExtensionMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Extensions;

use Doctrine\Common\EventManager;
use Doctrine\ORM\EntityManagerInterface;
use LaravelDoctrine\ORM\Extensions\Extension;
use LaravelDoctrineTest\ORM\Feature\Extensions\ExtensionManagerTest;

class ExtensionMock implements Extension
{
public function addSubscribers(EventManager $manager, EntityManagerInterface $em): void
{
// Confirm it gets called
(new ExtensionManagerTest)->assertTrue(true);
}

/**
* @return mixed[]
*/
public function getFilters(): array
{
return [];
}
}
22 changes: 22 additions & 0 deletions tests/Assets/Extensions/ExtensionMock2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Extensions;

use Doctrine\Common\EventManager;
use Doctrine\ORM\EntityManagerInterface;
use LaravelDoctrine\ORM\Extensions\Extension;

class ExtensionMock2 implements Extension
{
public function addSubscribers(EventManager $manager, EntityManagerInterface $em): void
{
}

/**
* @return mixed[]
*/
public function getFilters(): array
{
return [];
}
}
25 changes: 25 additions & 0 deletions tests/Assets/Extensions/ExtensionWithFiltersMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Extensions;

use Doctrine\Common\EventManager;
use Doctrine\ORM\EntityManagerInterface;
use LaravelDoctrine\ORM\Extensions\Extension;

class ExtensionWithFiltersMock implements Extension
{
public function addSubscribers(EventManager $manager, EntityManagerInterface $em): void
{
}

/**
* @return mixed[]
*/
public function getFilters(): array
{
return [
'filter' => 'FilterMock',
'filter2' => 'FilterMock'
];
}
}
9 changes: 9 additions & 0 deletions tests/Assets/FakeConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets;

use Doctrine\DBAL\Connection;

class FakeConnection extends Connection
{
}
7 changes: 7 additions & 0 deletions tests/Assets/FakeEventManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets;

class FakeEventManager extends \Doctrine\Common\EventManager
{
}
11 changes: 11 additions & 0 deletions tests/Assets/FilterStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets;

class FilterStub extends \Doctrine\ORM\Query\Filter\SQLFilter
{
public function addFilterConstraint(\Doctrine\ORM\Mapping\ClassMetadata $targetEntity, string $targetTableAlias): string
{
return '';
}
}
7 changes: 7 additions & 0 deletions tests/Assets/ListenerStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets;

class ListenerStub
{
}
20 changes: 20 additions & 0 deletions tests/Assets/Middleware/BindableEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Middleware;

class BindableEntity
{
public $id;

public $name;

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

public function getName()
{
return strtolower($this->name);
}
}
25 changes: 25 additions & 0 deletions tests/Assets/Middleware/BindableEntityWithInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Middleware;

class BindableEntityWithInterface implements \LaravelDoctrine\ORM\Contracts\UrlRoutable
{
public $id;

public $name;

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

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

public static function getRouteKeyNameStatic(): string
{
return 'name';
}
}
35 changes: 35 additions & 0 deletions tests/Assets/Middleware/EntityController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Middleware;

use Illuminate\Http\Request;

class EntityController
{
public function index(BindableEntity $entity)
{
return $entity->getName();
}

public function interfacer(BindableEntityWithInterface $entity)
{
return $entity->getId();
}

public function returnValue(string $value)
{
return $value;
}

public function returnEntity(BindableEntity $entity = null) {
return $entity;
}

public function returnEntityName(BindableEntity $entity) {
return $entity->getName();
}

public function checkRequest(Request $request) {
return $request instanceof Request ? 'request' : 'something else';
}
}
7 changes: 7 additions & 0 deletions tests/Assets/Mock/CountableEntityMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Mock;

class CountableEntityMock
{
}
15 changes: 15 additions & 0 deletions tests/Assets/Notifications/CustomNotifiableStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Notifications;

use LaravelDoctrine\ORM\Notifications\Notifiable;

class CustomNotifiableStub
{
use Notifiable;

public function routeNotificationForDoctrine()
{
return 'custom';
}
}
11 changes: 11 additions & 0 deletions tests/Assets/Notifications/NotifiableStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Notifications;

use LaravelDoctrine\ORM\Notifications\Notifiable;

class NotifiableStub
{
use Notifiable;
}

11 changes: 11 additions & 0 deletions tests/Assets/Notifications/NotificationDatabaseStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Notifications;

class NotificationDatabaseStub extends \Illuminate\Notifications\Notification
{
public function toDatabase()
{
return (new \LaravelDoctrine\ORM\Notifications\Notification());
}
}
7 changes: 7 additions & 0 deletions tests/Assets/Notifications/NotificationInvalidStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Notifications;

class NotificationInvalidStub extends \Illuminate\Notifications\Notification
{
}
Loading
Loading