/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.test.inject;

import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.spongepowered.api.Platform;
import org.spongepowered.api.Server;
import org.spongepowered.api.event.EventManager;
import org.spongepowered.api.network.ChannelRegistrar;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.plugin.PluginManager;
import org.spongepowered.common.SpongeGame;
import org.spongepowered.common.SpongePlatform;
import org.spongepowered.common.event.tracking.PhaseTracker;
import org.spongepowered.common.inject.SpongeImplementationModule;
import org.spongepowered.common.test.TestGame;
import org.spongepowered.common.test.TestServer;

import java.util.Optional;

public class TestImplementationModule extends SpongeImplementationModule {

    @Override
    protected void configure() {
        super.configure();

        this.bind(Server.class).to(TestServer.class);
        this.bind(SpongeGame.class).to(TestGame.class);
        this.bind(Platform.class).to(SpongePlatform.class);

        PluginManager manager = mock(PluginManager.class);
        PluginContainer mock = mock(PluginContainer.class);
        when(mock.getId()).thenReturn("sponge");
        when(manager.getPlugin(anyString())).thenReturn(Optional.of(mock));
        this.bind(PluginManager.class).toInstance(manager);


        this.bind(EventManager.class).toInstance(mock(EventManager.class));
        this.bind(ChannelRegistrar.class).toInstance(mock(ChannelRegistrar.class));
    }
}

@@ -1288,16 +1288,64 @@
 nject;%0A%0A
+import static org.mockito.ArgumentMatchers.any;%0A
 import s
@@ -2373,43 +2373,33 @@
     
-this.bind(Platform.class).to(Sponge
+Platform platform = mock(
 Plat
@@ -2411,17 +2411,16 @@
 class);%0A
-%0A
         
@@ -2429,23 +2429,22 @@
 ugin
-Manager manager
+Container mock
  = m
@@ -2449,29 +2449,31 @@
  mock(Plugin
-Manag
+Contain
 er.class);%0A 
@@ -2483,49 +2483,166 @@
     
-PluginContainer mock = mock(PluginContain
+when(platform.getContainer(any())).thenReturn(mock);%0A        this.bind(Platform.class).toInstance(platform);%0A%0A        PluginManager manager = mock(PluginManag
 er.c
@@ -2769,24 +2769,97 @@
 .of(mock));%0A
+        when(manager.fromInstance(any())).thenReturn(Optional.of(mock));%0A
         this

Fix unit tests for now added phase tracker during unit tests.