diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..388ce13 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,13 @@ +| Q | A +| ---------------- | ----- +| Bug report? | yes/no +| Feature request? | yes/no +| Novo SGA version | x.y.z +| PHP version | x.y.z +| Database version | MySQL 5.7/PostgreSQL 15 +| Platform/OS | Linux/Windows + + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..10f5bd2 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,24 @@ +name: CI + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: shivammathur/setup-php@2.28.0 + with: + php-version: 8.2 + + - name: Install dependencies + run: composer install + + - name: PHP Code Standards + run: vendor/bin/phpcs + + - name: PHP Code Analysis + run: vendor/bin/phpstan + + - name: PHP Unit Tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 2b1bf5a..3a02cfb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor/ composer.lock .phpcs-cache +.phpunit.result.cache diff --git a/composer.json b/composer.json index e2c4b48..4121477 100644 --- a/composer.json +++ b/composer.json @@ -6,12 +6,16 @@ "psr-4": { "Novosga\\": "src/" } }, "autoload-dev": { - "psr-4": { "Novosga\\": "tests/" } + "psr-4": { "Novosga\\Tests\\": "tests/" } }, "require": { "php": ">=8.2", "doctrine/orm": "^3.2", - "symfony/http-kernel": "7.1.*" + "symfony/http-kernel": "7.1.*", + "symfony/form": "7.1.*", + "symfony/event-dispatcher-contracts": "^3.5", + "symfony/validator": "7.1.*", + "symfony/security-core": "7.1.*" }, "require-dev": { "phpstan/phpstan": "^1.10", diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..b545cee --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + src/ + tests/ + + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..d268c2f --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 6 + paths: + - src/ + - tests/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..8a916fc --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + tests + + + + + + src + + + + + + diff --git a/src/Configuration/OrderingParameter.php b/src/Configuration/OrderingParameter.php deleted file mode 100644 index 67ee625..0000000 --- a/src/Configuration/OrderingParameter.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Configuration; - -use Doctrine\ORM\QueryBuilder; -use Novosga\Entity\Unidade; -use Novosga\Entity\Usuario; -use Novosga\Infrastructure\StorageInterface; - -/** - * OrderingParameter - * - * @author Rogerio Lino - */ -class OrderingParameter implements ParameterInterface -{ - /** - * @var Unidade - */ - private $unidade; - - /** - * @var Usuario - */ - private $usuario; - - /** - * @var StorageInterface - */ - private $storage; - - /** - * @var QueryBuilder - */ - private $queryBuilder; - - public function getUnidade(): Unidade - { - return $this->unidade; - } - - public function getUsuario(): ?Usuario - { - return $this->usuario; - } - - public function getStorage(): StorageInterface - { - return $this->storage; - } - - public function getQueryBuilder(): QueryBuilder - { - return $this->queryBuilder; - } - - public function setUnidade(Unidade $unidade) - { - $this->unidade = $unidade; - return $this; - } - - public function setUsuario(?Usuario $usuario) - { - $this->usuario = $usuario; - return $this; - } - - public function setStorage(StorageInterface $storage) - { - $this->storage = $storage; - return $this; - } - - public function setQueryBuilder(QueryBuilder $queryBuilder) - { - $this->queryBuilder = $queryBuilder; - return $this; - } -} diff --git a/src/Configuration/ParameterInterface.php b/src/Configuration/ParameterInterface.php deleted file mode 100644 index f67f0e3..0000000 --- a/src/Configuration/ParameterInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Configuration; - -/** - * Configuration file parameter interface - * - * @author Rogerio Lino - */ -interface ParameterInterface -{ -} diff --git a/src/Entity/AtendimentoInterface.php b/src/Entity/AtendimentoInterface.php index e85670d..58ccf92 100644 --- a/src/Entity/AtendimentoInterface.php +++ b/src/Entity/AtendimentoInterface.php @@ -85,7 +85,7 @@ public function setTempoAtendimento(DateInterval $tempoAtendimento): static; public function getTempoAtendimento(): DateInterval; public function setTempoDeslocamento(DateInterval $tempoDeslocamento): static; - public function getTempoDeslocamento(); + public function getTempoDeslocamento(): DateInterval; public function getCliente(): ?ClienteInterface; public function setCliente(ClienteInterface $cliente): static; diff --git a/src/Entity/EntityMetadataInterface.php b/src/Entity/EntityMetadataInterface.php index ced03a1..8a2065e 100644 --- a/src/Entity/EntityMetadataInterface.php +++ b/src/Entity/EntityMetadataInterface.php @@ -15,9 +15,9 @@ /** * EntityMetadataInterface. - * + * * @template T - * + * * @author Rogerio Lino */ interface EntityMetadataInterface extends MetadataInterface diff --git a/src/Event/AdvancedEvent.php b/src/Event/AdvancedEvent.php deleted file mode 100644 index 3bd4761..0000000 --- a/src/Event/AdvancedEvent.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -/** - * AdvancedEvent - * - * @author Rogerio Lino - */ -class AdvancedEvent extends Event implements - LoggerAwareEventInterface, - StorageAwareEventInterface, - UserAwareEventInterface -{ - use LoggerAwareTrait, - StorageAwareTrait, - UserAwareTrait; -} diff --git a/src/Event/Event.php b/src/Event/Event.php deleted file mode 100644 index 660bfa5..0000000 --- a/src/Event/Event.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -/** - * Event - * - * @author Rogerio Lino - */ -class Event implements EventInterface -{ - /** - * @var string - */ - private $name; - - /** - * @var mixed - */ - private $data; - - public function __construct(string $name, $data) - { - $this->name = $name; - $this->data = $data; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return $this->data; - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return $this->name; - } -} diff --git a/src/Event/EventDispatcherInterface.php b/src/Event/EventDispatcherInterface.php deleted file mode 100644 index bdf6446..0000000 --- a/src/Event/EventDispatcherInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -/** - * EventDispatcherInterface - * - * @author Rogerio Lino - */ -interface EventDispatcherInterface -{ - /** - * @param EventInterface $event - * @return bool - */ - public function dispatch(EventInterface $event): bool; - - /** - * - * @param string $eventName - * @param mixed $eventData - * @param bool $advancedEvent - * @return bool - */ - public function createAndDispatch(string $eventName, $eventData, bool $advancedEvent = false): bool; -} diff --git a/src/Event/EventInterface.php b/src/Event/EventInterface.php deleted file mode 100644 index e0c2499..0000000 --- a/src/Event/EventInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -/** - * Event - * - * @author Rogerio Lino - */ -interface EventInterface -{ - /** - * Returns event name - * - * @return string - */ - public function getName(): string; - - /** - * Returns event data - * - * @return mixed - */ - public function getData(); -} diff --git a/src/Event/LoggerAwareEventInterface.php b/src/Event/LoggerAwareEventInterface.php deleted file mode 100644 index f4d2b77..0000000 --- a/src/Event/LoggerAwareEventInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -use Psr\Log\LoggerInterface; - -/** - * LoggerAwareEventInterface - * - * @author Rogerio Lino - */ -interface LoggerAwareEventInterface extends EventInterface -{ - /** - * @param LoggerInterface $logger - */ - public function setLogger(LoggerInterface $logger); - - /** - * @return LoggerInterface - */ - public function getLogger(): LoggerInterface; -} diff --git a/src/Event/LoggerAwareTrait.php b/src/Event/LoggerAwareTrait.php deleted file mode 100644 index 604b4f8..0000000 --- a/src/Event/LoggerAwareTrait.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -use Psr\Log\LoggerInterface; - -/** - * LoggerAwareTrait - * - * @author Rogerio Lino - */ -trait LoggerAwareTrait -{ - /** - * @var LoggerInterface - */ - private $storage; - - /** - * {@inheritdoc} - */ - public function setLogger(LoggerInterface $storage) - { - $this->storage = $storage; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getLogger(): LoggerInterface - { - return $this->storage; - } -} diff --git a/src/Event/PreUserSetLocalEvent.php b/src/Event/PreUserSetLocalEvent.php new file mode 100644 index 0000000..6ba0d45 --- /dev/null +++ b/src/Event/PreUserSetLocalEvent.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Novosga\Event; + +use Novosga\Entity\LocalInterface; +use Novosga\Entity\UnidadeInterface; +use Novosga\Entity\UsuarioInterface; + +/** + * PreUserSetLocalEvent + * + * @author Rogerio Lino + */ +final readonly class PreUserSetLocalEvent +{ + public function __construct( + public UnidadeInterface $unidade, + public UsuarioInterface $usuario, + public LocalInterface $local, + public string|int $numbero, + public string $tipo, + ) { + } +} diff --git a/src/Event/QueueOrderingEvent.php b/src/Event/QueueOrderingEvent.php new file mode 100644 index 0000000..5d5679e --- /dev/null +++ b/src/Event/QueueOrderingEvent.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Novosga\Configuration; + +use Doctrine\ORM\QueryBuilder; +use Novosga\Entity\UnidadeInterface; +use Novosga\Entity\UsuarioInterface; +use Symfony\Contracts\EventDispatcher\Event; + +/** + * QueueOrderingEvent + * + * @author Rogerio Lino + */ +final class QueueOrderingEvent extends Event +{ + public function __construct( + public readonly UnidadeInterface $unidade, + public readonly UsuarioInterface $usuario, + public readonly QueryBuilder $queryBuilder, + ) { + } +} diff --git a/src/Event/StorageAwareEventInterface.php b/src/Event/StorageAwareEventInterface.php deleted file mode 100644 index ff3d0af..0000000 --- a/src/Event/StorageAwareEventInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -use Novosga\Infrastructure\StorageInterface; - -/** - * StorageAwareEventInterface - * - * @author Rogerio Lino - */ -interface StorageAwareEventInterface extends EventInterface -{ - /** - * @param StorageInterface $storage - */ - public function setStorage(StorageInterface $storage); - - /** - * @return StorageInterface - */ - public function getStorage(): StorageInterface; -} diff --git a/src/Event/StorageAwareTrait.php b/src/Event/StorageAwareTrait.php deleted file mode 100644 index 6e3397c..0000000 --- a/src/Event/StorageAwareTrait.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -use Novosga\Infrastructure\StorageInterface; - -/** - * StorageAwareTrait - * - * @author Rogerio Lino - */ -trait StorageAwareTrait -{ - /** - * @var StorageInterface - */ - private $storage; - - /** - * {@inheritdoc} - */ - public function setStorage(StorageInterface $storage) - { - $this->storage = $storage; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getStorage(): StorageInterface - { - return $this->storage; - } -} diff --git a/src/Event/UserAwareEventInterface.php b/src/Event/UserAwareEventInterface.php deleted file mode 100644 index 2851b8f..0000000 --- a/src/Event/UserAwareEventInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -use Novosga\Entity\Usuario; - -/** - * UserAwareEventInterface - * - * @author Rogerio Lino - */ -interface UserAwareEventInterface extends EventInterface -{ - /** - * @param Usuario $user - */ - public function setUser(Usuario $user); - - /** - * @return Usuario - */ - public function getUser(): Usuario; -} diff --git a/src/Event/UserAwareTrait.php b/src/Event/UserAwareTrait.php deleted file mode 100644 index 18931b6..0000000 --- a/src/Event/UserAwareTrait.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Novosga\Event; - -use Novosga\Entity\Usuario; - -/** - * UserAwareTrait - * - * @author Rogerio Lino - */ -trait UserAwareTrait -{ - /** - * @var Usuario - */ - private $user; - - /** - * {@inheritdoc} - */ - public function setUser(Usuario $user) - { - $this->user = $user; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getUser(): Usuario - { - return $this->user; - } -} diff --git a/src/Event/UserSetLocalEvent.php b/src/Event/UserSetLocalEvent.php new file mode 100644 index 0000000..45b3d0f --- /dev/null +++ b/src/Event/UserSetLocalEvent.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Novosga\Event; + +use Novosga\Entity\LocalInterface; +use Novosga\Entity\UnidadeInterface; +use Novosga\Entity\UsuarioInterface; + +/** + * UserSetLocalEvent + * + * @author Rogerio Lino + */ +final readonly class UserSetLocalEvent +{ + public function __construct( + public UnidadeInterface $unidade, + public UsuarioInterface $usuario, + public LocalInterface $local, + public string|int $numbero, + public string $tipo, + ) { + } +} diff --git a/src/Form/ClienteType.php b/src/Form/ClienteType.php index bfd499f..7f26a16 100644 --- a/src/Form/ClienteType.php +++ b/src/Form/ClienteType.php @@ -26,10 +26,6 @@ class ClienteType extends AbstractType { - /** - * @param FormBuilderInterface $builder - * @param array $options - */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder diff --git a/src/Http/Envelope.php b/src/Http/Envelope.php index 65f7db9..ab732d6 100644 --- a/src/Http/Envelope.php +++ b/src/Http/Envelope.php @@ -22,115 +22,97 @@ */ class Envelope implements \JsonSerializable { - /** - * @var bool - */ - private $success; - - /** - * @var string - */ - private $sessionStatus; - - /** - * @var mixed - */ - private $data; - - /** - * @var string - */ - private $message; - - /** - * @var string - */ - private $detail; - - public function __construct($data = null) - { - $this->data = $data; - $this->success = true; - $this->sessionStatus = 'active'; + private bool $success = true; + private string $sessionStatus = 'active'; + private ?string $message = null; + private ?string $detail = null; + + public function __construct( + private mixed $data = null + ) { } - - public function isSuccess() + + public function isSuccess(): bool { return $this->success; } - public function getSessionStatus() + public function setSuccess(bool $success): static { - return $this->sessionStatus; - } + $this->success = $success; - public function getData() - { - return $this->data; + return $this; } - public function getMessage() + public function getSessionStatus(): string { - return $this->message; + return $this->sessionStatus; } - public function setSuccess($success) + public function setSessionStatus(string $session): static { - $this->success = $success; + $this->sessionStatus = $session; + return $this; } - public function setSessionStatus($session) + public function getData(): mixed { - $this->sessionStatus = $session; - return $this; + return $this->data; } - public function setData($data) + public function setData(mixed $data): static { $this->data = $data; + return $this; } - public function setMessage($message) + public function getMessage(): ?string + { + return $this->message; + } + + public function setMessage(?string $message): static { $this->message = $message; + return $this; } - - public function getDetail() + + public function getDetail(): ?string { return $this->detail; } - public function setDetail($detail) + public function setDetail(?string $detail): static { $this->detail = $detail; return $this; } - - public function exception(Throwable $e, $debug = false) + + public function exception(Throwable $e, bool $debug = false): static { $this ->setSuccess(false) ->setMessage($e->getMessage()); - + if ($debug) { - $detail = "{$e->getFile()}:{$e->getLine()}\n{$e->getTraceAsString()}"; - $this->setDetail($detail); + $this->setDetail("{$e->getFile()}:{$e->getLine()}\n{$e->getTraceAsString()}"); } - + return $this; } - - public function jsonSerialize() + + /** @return array */ + public function jsonSerialize(): array { $body = [ - 'success' => $this->success, - 'sessionStatus' => $this->sessionStatus, - 'time' => time() * 1000, + 'success' => $this->success, + 'sessionStatus' => $this->sessionStatus, + 'time' => time() * 1000, ]; - + if ($this->success) { $body['data'] = $this->data; } else { @@ -139,7 +121,7 @@ public function jsonSerialize() $body['detail'] = $this->detail; } } - + return $body; } } diff --git a/src/Infrastructure/StorageInterface.php b/src/Infrastructure/StorageInterface.php index d7d4383..68855bb 100644 --- a/src/Infrastructure/StorageInterface.php +++ b/src/Infrastructure/StorageInterface.php @@ -29,6 +29,11 @@ interface StorageInterface { public function getManager(): EntityManagerInterface; + /** + * @template T of object + * @param class-string $className + * @return EntityRepository + */ public function getRepository(string $className): EntityRepository; /** Gera uma nova senha de atendimento */ @@ -37,7 +42,11 @@ public function distribui(AtendimentoInterface $atendimento, AgendamentoInterfac public function chamar(AtendimentoInterface $atendimento): void; /** @param AtendimentoCodificadoInterface[] $codificados */ - public function encerrar(AtendimentoInterface $atendimento, array $codificados, AtendimentoInterface $novoAtendimento = null): void; + public function encerrar( + AtendimentoInterface $atendimento, + array $codificados, + AtendimentoInterface $novoAtendimento = null + ): void; /** * Move os dados de atendimento para o histórico diff --git a/src/Module/BaseModule.php b/src/Module/BaseModule.php index 6a6f058..99b0b6d 100644 --- a/src/Module/BaseModule.php +++ b/src/Module/BaseModule.php @@ -22,16 +22,18 @@ */ abstract class BaseModule extends Bundle implements ModuleInterface { - public function getKeyName() + public function getKeyName(): string { $namespace = $this->getNamespace(); $tokens = explode('\\', str_replace('Bundle', '', $namespace)); + return strtolower(implode('.', $tokens)); } - - public function getRoleName() + + public function getRoleName(): string { $keyName = $this->getKeyName(); + return 'ROLE_' . strtoupper(str_replace('.', '_', $keyName)); } diff --git a/src/Module/ModuleInterface.php b/src/Module/ModuleInterface.php index d48d6af..111d9a7 100644 --- a/src/Module/ModuleInterface.php +++ b/src/Module/ModuleInterface.php @@ -20,15 +20,15 @@ */ interface ModuleInterface { - public function getKeyName(); - - public function getRoleName(); - - public function getIconName(); + public function getKeyName(): string; - public function getDisplayName(); + public function getRoleName(): string; - public function getName(); + public function getIconName(): string; - public function getHomeRoute(); + public function getDisplayName(): string; + + public function getName(): string; + + public function getHomeRoute(): string; } diff --git a/src/Repository/EntityMetadataRepositoryInterface.php b/src/Repository/EntityMetadataRepositoryInterface.php index a3b8030..cb38dce 100644 --- a/src/Repository/EntityMetadataRepositoryInterface.php +++ b/src/Repository/EntityMetadataRepositoryInterface.php @@ -33,18 +33,18 @@ interface EntityMetadataRepositoryInterface extends ObjectRepository, BaseReposi */ public function findByNamespace($entity, string $namespace): array; - /** + /** * @param E $entity * @return ?T */ public function get($entity, string $namespace, string $name); - + /** * @param E $entity * @return T */ public function set($entity, string $namespace, string $name, mixed $value = null); - + /** @param E $entity */ public function remove($entity, string $namespace, string $name): void; } diff --git a/src/Repository/ServicoUnidadeRepositoryInterface.php b/src/Repository/ServicoUnidadeRepositoryInterface.php index 7fa3af1..e2a4bc6 100644 --- a/src/Repository/ServicoUnidadeRepositoryInterface.php +++ b/src/Repository/ServicoUnidadeRepositoryInterface.php @@ -32,7 +32,7 @@ interface ServicoUnidadeRepositoryInterface extends ObjectRepository, BaseReposi * @return ServicoUnidadeInterface[] */ public function getAll(UnidadeInterface|int $unidade): array; - + /** * Retorna o relacionamento entre o serviço e a unidade. */ diff --git a/src/Repository/ServicoUsuarioRepositoryInterface.php b/src/Repository/ServicoUsuarioRepositoryInterface.php index d8d674f..c7c832a 100644 --- a/src/Repository/ServicoUsuarioRepositoryInterface.php +++ b/src/Repository/ServicoUsuarioRepositoryInterface.php @@ -21,7 +21,7 @@ /** * ServicoUsuarioRepositoryInterface - * + * * @extends ObjectRepository * * @author Rogério Lino @@ -33,7 +33,7 @@ interface ServicoUsuarioRepositoryInterface extends ObjectRepository, BaseReposi * @return ServicoUsuarioInterface[] */ public function getAll(UsuarioInterface|int $usuario, UnidadeInterface|int $unidade): array; - + /** * Retorna o relacionamento entre o serviço e a usuario. */ diff --git a/src/Repository/UnidadeRepositoryInterface.php b/src/Repository/UnidadeRepositoryInterface.php index 9f0fccd..a4fcb22 100644 --- a/src/Repository/UnidadeRepositoryInterface.php +++ b/src/Repository/UnidadeRepositoryInterface.php @@ -26,7 +26,6 @@ */ interface UnidadeRepositoryInterface extends ObjectRepository, BaseRepository { - /** * Retorna as unidades disponíveis para o usuário * @return UnidadeInterface[] diff --git a/src/Repository/UsuarioRepositoryInterface.php b/src/Repository/UsuarioRepositoryInterface.php index f412941..aeaffc6 100644 --- a/src/Repository/UsuarioRepositoryInterface.php +++ b/src/Repository/UsuarioRepositoryInterface.php @@ -33,9 +33,10 @@ interface UsuarioRepositoryInterface extends ObjectRepository, BaseRepository * @return UsuarioInterface[] */ public function findByUnidade(UnidadeInterface $unidade, Criteria $criteria = null): array; - + /** * Retorna os usuários que atendem o serviço da unidade + * @return UsuarioInterface[] */ public function findByServicoUnidade(ServicoUnidadeInterface $servicoUnidade, Criteria $criteria = null): array; } diff --git a/src/Service/AtendimentoServiceInterface.php b/src/Service/AtendimentoServiceInterface.php index 32778d7..d27b46c 100644 --- a/src/Service/AtendimentoServiceInterface.php +++ b/src/Service/AtendimentoServiceInterface.php @@ -13,6 +13,7 @@ namespace Novosga\Service; +use Exception; use Novosga\Entity\AgendamentoInterface; use Novosga\Entity\AtendimentoInterface; use Novosga\Entity\ClienteInterface; @@ -34,17 +35,17 @@ interface AtendimentoServiceInterface public const ATTR_NAMESPACE = 'global'; // estados do atendimento - const SENHA_EMITIDA = 'emitida'; - const CHAMADO_PELA_MESA = 'chamado'; - const ATENDIMENTO_INICIADO = 'iniciado'; - const ATENDIMENTO_ENCERRADO = 'encerrado'; - const NAO_COMPARECEU = 'nao_compareceu'; - const SENHA_CANCELADA = 'cancelada'; - const ERRO_TRIAGEM = 'erro_triagem'; + public const SENHA_EMITIDA = 'emitida'; + public const CHAMADO_PELA_MESA = 'chamado'; + public const ATENDIMENTO_INICIADO = 'iniciado'; + public const ATENDIMENTO_ENCERRADO = 'encerrado'; + public const NAO_COMPARECEU = 'nao_compareceu'; + public const SENHA_CANCELADA = 'cancelada'; + public const ERRO_TRIAGEM = 'erro_triagem'; // resolucoes - const RESOLVIDO = 'resolvido'; - const PENDENTE = 'pendente'; + public const RESOLVIDO = 'resolvido'; + public const PENDENTE = 'pendente'; public function getById(int $id): ?AtendimentoInterface; @@ -58,8 +59,13 @@ public function getNomeSituacao(string $status): string; /** * Cria ou retorna um metadado do atendimento caso o $value seja null (ou ocultado). + * @return ?EntityMetadataInterface */ - public function meta(AtendimentoInterface $atendimento, string $name, mixed $value = null): ?EntityMetadataInterface; + public function meta( + AtendimentoInterface $atendimento, + string $name, + mixed $value = null + ): ?EntityMetadataInterface; public function buscaAtendimento(UnidadeInterface $unidade, int $id): ?AtendimentoInterface; diff --git a/src/Service/UnidadeServiceInterface.php b/src/Service/UnidadeServiceInterface.php index ed0d080..e5ab74c 100644 --- a/src/Service/UnidadeServiceInterface.php +++ b/src/Service/UnidadeServiceInterface.php @@ -35,5 +35,9 @@ public function getById(int $id): ?UnidadeInterface; */ public function meta(UnidadeInterface $unidade, string $name, mixed $value = null): ?EntityMetadataInterface; - public function addServicoUnidade(ServicoInterface $servico, UnidadeInterface $unidade, string $sigla): ServicoUnidadeInterface; + public function addServicoUnidade( + ServicoInterface $servico, + UnidadeInterface $unidade, + string $sigla + ): ServicoUnidadeInterface; } diff --git a/src/Service/UsuarioServiceInterface.php b/src/Service/UsuarioServiceInterface.php index 8fb461c..d89062d 100644 --- a/src/Service/UsuarioServiceInterface.php +++ b/src/Service/UsuarioServiceInterface.php @@ -13,7 +13,6 @@ namespace Novosga\Service; -use App\Entity\ServicoUsuario; use Novosga\Entity\EntityMetadataInterface; use Novosga\Entity\ServicoInterface; use Novosga\Entity\ServicoUsuarioInterface; @@ -55,24 +54,29 @@ public function getServicoUsuario( */ public function getServicosUnidade(UsuarioInterface $usuario, UnidadeInterface $unidade): array; - public function updateAtendente(UsuarioInterface $usuario, ?string $tipoAtendimento, ?int $local, ?int $numero): void; + public function updateAtendente( + UsuarioInterface $usuario, + ?string $tipoAtendimento, + ?int $local, + ?int $numero, + ): void; public function addServicoUsuario( UsuarioInterface $usuario, ServicoInterface $servico, UnidadeInterface $unidade - ): ServicoUsuario; + ): ServicoUsuarioInterface; public function removeServicoUsuario( UsuarioInterface $usuario, ServicoInterface $servico, UnidadeInterface $unidade - ): ?ServicoUsuario; + ): ?ServicoUsuarioInterface; public function updateServicoUsuario( UsuarioInterface $usuario, ServicoInterface $servico, UnidadeInterface $unidade, int $peso, - ): ?ServicoUsuario; + ): ?ServicoUsuarioInterface; } diff --git a/tests/Module/BaseModuleTest.php b/tests/Module/BaseModuleTest.php new file mode 100644 index 0000000..f404b84 --- /dev/null +++ b/tests/Module/BaseModuleTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Novosga\Tests\Module; + +use PHPUnit\Framework\TestCase; + +/** + * BaseModuleTest + * + * @author Rogerio Lino + */ +class BaseModuleTest extends TestCase +{ + public function testKeyName(): void + { + $bundle = new DummyTestBundle(); + $this->assertSame('novosga.tests.module', $bundle->getKeyName()); + } + + public function testRoleName(): void + { + $bundle = new DummyTestBundle(); + $this->assertSame('ROLE_NOVOSGA_TESTS_MODULE', $bundle->getRoleName()); + } + + public function testDomainName(): void + { + $this->assertSame('DummyTestBundle', DummyTestBundle::getDomain()); + } +} diff --git a/tests/Module/DummyTestBundle.php b/tests/Module/DummyTestBundle.php new file mode 100644 index 0000000..83269b7 --- /dev/null +++ b/tests/Module/DummyTestBundle.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Novosga\Tests\Module; + +use Novosga\Module\BaseModule; + +/** + * BaseModuleTest + * + * @author Rogerio Lino + */ +class DummyTestBundle extends BaseModule +{ + public function getIconName(): string + { + return 'fa-dummy'; + } + + public function getDisplayName(): string + { + return 'Dummy Bundle'; + } + + public function getHomeRoute(): string + { + return 'dummy_bundle_index'; + } +}