def METHOD_NAME(
    config, emitter, mock_provider, tmp_path, mock_instance_name, mock_is_base_available
):
    """Test clean with a complex list of bases."""
    config.name = "foo"
    bases_config = [
        BasesConfiguration(
            **{
                "build-on": [
                    Base(name="x1name", channel="x1channel", architectures=["x1arch"]),
                ],
                "run-on": [
                    Base(name="x2name", channel="x2channel", architectures=["x2arch"]),
                ],
            }
        ),
        BasesConfiguration(
            **{
                "build-on": [
                    Base(name="x3name", channel="x3channel", architectures=["x3arch"]),
                    Base(name="x3name", channel="x3channel", architectures=["x3arch"]),
                ],
                "run-on": [
                    Base(name="x4name", channel="x4channel", architectures=["x4arch"]),
                ],
            }
        ),
        BasesConfiguration(
            **{
                "build-on": [
                    Base(name="x5name", channel="x5channel", architectures=["x5arch"]),
                ],
                "run-on": [
                    Base(name="x6name", channel="x6channel", architectures=["x6arch"]),
                    Base(
                        name="x7name",
                        channel="x7channel",
                        architectures=["x7arch1", "x7arch2"],
                    ),
                ],
            }
        ),
    ]
    config.set(bases=bases_config)
    cmd = CleanCommand(config)
    cmd.run([])
    assert mock_provider.mock_calls == [
        mock.call.clean_project_environments(instance_name="test-instance-name-0"),
        mock.call.clean_project_environments(instance_name="test-instance-name-1"),
        mock.call.clean_project_environments(instance_name="test-instance-name-2"),
    ]
    assert mock_instance_name.mock_calls == [
        mock.call(
            bases_index=0,
            build_on_index=0,
            project_name="foo",
            project_path=tmp_path,
            target_arch=get_host_architecture(),
        ),
        mock.call(
            bases_index=1,
            build_on_index=0,
            project_name="foo",
            project_path=tmp_path,
            target_arch=get_host_architecture(),
        ),
        mock.call(
            bases_index=2,
            build_on_index=0,
            project_name="foo",
            project_path=tmp_path,
            target_arch=get_host_architecture(),
        ),
    ]
    assert mock_is_base_available.mock_calls == [
        mock.call.is_base_available(
            Base(name="x1name", channel="x1channel", architectures=["x1arch"])
        ),
        mock.call.is_base_available(
            Base(name="x3name", channel="x3channel", architectures=["x3arch"])
        ),
        mock.call.is_base_available(
            Base(name="x5name", channel="x5channel", architectures=["x5arch"])
        ),
    ]
    emitter.assert_message("Cleaning project 'foo'.")
    emitter.assert_debug("Cleaning environment 'test-instance-name-0'")
    emitter.assert_debug("Cleaning environment 'test-instance-name-1'")
    emitter.assert_debug("Cleaning environment 'test-instance-name-2'")
    emitter.assert_message("Cleaned project 'foo'.")