-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional test and fix container usage (#472)
* Add functional test * Fix action service id * Bump doctrine-bundle * Deprecate instantiating TokenStorageUsernameCallable with Container
- Loading branch information
Showing
16 changed files
with
395 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SimpleThings\EntityAudit\Tests\App; | ||
|
||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; | ||
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle; | ||
use SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Bundle\SecurityBundle\SecurityBundle; | ||
use Symfony\Bundle\TwigBundle\TwigBundle; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpFoundation\InputBag; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; | ||
|
||
final class AppKernel extends Kernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('test', false); | ||
} | ||
|
||
public function registerBundles(): iterable | ||
{ | ||
return [ | ||
new FrameworkBundle(), | ||
new TwigBundle(), | ||
new DoctrineBundle(), | ||
new SecurityBundle(), | ||
new DoctrineFixturesBundle(), | ||
new SimpleThingsEntityAuditBundle(), | ||
]; | ||
} | ||
|
||
public function getCacheDir(): string | ||
{ | ||
return sprintf('%scache', $this->getBaseDir()); | ||
} | ||
|
||
public function getLogDir(): string | ||
{ | ||
return sprintf('%slog', $this->getBaseDir()); | ||
} | ||
|
||
public function getProjectDir(): string | ||
{ | ||
return __DIR__; | ||
} | ||
|
||
/** | ||
* TODO: add typehint when support for Symfony < 5.1 is dropped. | ||
* | ||
* @param RoutingConfigurator $routes | ||
*/ | ||
protected function configureRoutes($routes): void | ||
{ | ||
$routes->import(sprintf('%s/config/routes.yml', $this->getProjectDir())); | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void | ||
{ | ||
$loader->load(__DIR__.'/config/config.yml'); | ||
|
||
if (class_exists(InputBag::class)) { | ||
$loader->load(__DIR__.'/config/config_symfony_v5.yml'); | ||
} else { | ||
$loader->load(__DIR__.'/config/config_symfony_v4.yml'); | ||
} | ||
|
||
$loader->load(__DIR__.'/config/services.php'); | ||
} | ||
|
||
private function getBaseDir(): string | ||
{ | ||
return sprintf('%s/entity-audit-bundle/var/', sys_get_temp_dir()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SimpleThings\EntityAudit\Tests\App\DataFixtures; | ||
|
||
use Doctrine\Bundle\FixturesBundle\Fixture; | ||
use Doctrine\Persistence\ObjectManager; | ||
use SimpleThings\EntityAudit\Tests\App\Entity\User; | ||
|
||
final class UserFixture extends Fixture | ||
{ | ||
public function load(ObjectManager $manager): void | ||
{ | ||
$user = new User('bob'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
||
$user->setName('alice'); | ||
|
||
$manager->flush(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SimpleThings\EntityAudit\Tests\App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\Table(name="bundle_user") | ||
*/ | ||
class User | ||
{ | ||
/** | ||
* @var int|null | ||
* | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
* @ORM\GeneratedValue | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string") | ||
*/ | ||
private $name; | ||
|
||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
framework: | ||
secret: '%env(APP_SECRET)%' | ||
test: true | ||
|
||
twig: | ||
exception_controller: null | ||
strict_variables: false | ||
|
||
parameters: | ||
env(DATABASE_URL): 'sqlite:////%kernel.cache_dir%/test_database.db' | ||
|
||
doctrine: | ||
dbal: | ||
url: "%env(resolve:DATABASE_URL)%" | ||
orm: | ||
auto_generate_proxy_classes: true | ||
auto_mapping: true | ||
mappings: | ||
AuditEntityTest: | ||
type: annotation | ||
dir: "%kernel.project_dir%/Entity" | ||
is_bundle: false | ||
prefix: SimpleThings\EntityAudit\Tests\App\Entity | ||
|
||
simple_things_entity_audit: | ||
revision_table_name: bundle_revisions | ||
audited_entities: | ||
- SimpleThings\EntityAudit\Tests\App\Entity\User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
framework: | ||
session: | ||
storage_id: session.storage.mock_file | ||
|
||
security: | ||
firewalls: | ||
main: | ||
anonymous: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
framework: | ||
session: | ||
storage_factory_id: session.storage.factory.mock_file | ||
router: | ||
utf8: true | ||
|
||
security: | ||
enable_authenticator_manager: true | ||
firewalls: | ||
main: | ||
lazy: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
simple_things_entity_audit: | ||
resource: "@SimpleThingsEntityAuditBundle/Resources/config/routing/audit.xml" | ||
prefix: /audit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->services() | ||
->defaults() | ||
->autowire() | ||
->autoconfigure() | ||
->load('SimpleThings\\EntityAudit\\Tests\\App\\DataFixtures\\', dirname(__DIR__).'/DataFixtures'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.