From 560eb85f4b7bab62a0bb9014d8c5317aeb8130d9 Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Thu, 22 Feb 2018 12:23:47 +0200 Subject: [PATCH] Added provider tests. --- tests/Provider/EventTest.php | 25 ++++++++++++++++++++++++ tests/Provider/ManagerTest.php | 29 ++++++++++++++++++++++++++++ tests/Provider/RecordTest.php | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 tests/Provider/EventTest.php create mode 100644 tests/Provider/ManagerTest.php create mode 100644 tests/Provider/RecordTest.php diff --git a/tests/Provider/EventTest.php b/tests/Provider/EventTest.php new file mode 100644 index 0000000..c76198e --- /dev/null +++ b/tests/Provider/EventTest.php @@ -0,0 +1,25 @@ +register( $container ); + + $this->assertArrayHasKey( 'hook.events', $container ); + + foreach ( $container['hook.events'] as $config ) { + $this->assertInstanceOf( Hook_Event_Config_Interface::class, $config ); + } + } +} diff --git a/tests/Provider/ManagerTest.php b/tests/Provider/ManagerTest.php new file mode 100644 index 0000000..98e09fe --- /dev/null +++ b/tests/Provider/ManagerTest.php @@ -0,0 +1,29 @@ +register( $container ); + + $this->assertArrayHasKey( 'managers', $container ); + + $container->extend( 'managers', function () {} ); + $provider->boot( $container ); + $this->expectException( FrozenServiceException::class ); + $container->extend( 'managers', function () {} ); + } +} diff --git a/tests/Provider/RecordTest.php b/tests/Provider/RecordTest.php new file mode 100644 index 0000000..fbee7aa --- /dev/null +++ b/tests/Provider/RecordTest.php @@ -0,0 +1,35 @@ +register( $container ); + + $stopwatch_a = $container['stopwatch']; + $stopwatch_b = $container['stopwatch']; + + $this->assertNotSame( $stopwatch_a, $stopwatch_b ); + + $this->assertArrayHasKey( 'records', $container ); + + $container->extend( 'collectors', function () {} ); + $provider->boot( $container ); + $this->expectException( FrozenServiceException::class ); + $container->extend( 'collectors', function () {} ); + + } +}