<?php

class Wiaas_Package_Addon_Test extends Wiaas_Unit_Test_Case {

	/**
	 * @covers Wiaas_Package_Addon::register_addon_package_type()
	 */
	function test_addon_package_type_registered() {
		$package_types = Wiaas_Package_Type::get_available_package_types();

		$this->assertContains('add_on', $package_types);
	}

	/**
	 * @covers Wiaas_Package_Addon::set_package_addons()
	 * @covers Wiaas_Package_Addon::get_package_addons()
	 */
	function test_adding_package_addons() {
		$package = $this->create_new_package();

		$addon1 = $this->create_new_package();
		$addon2 = $this->create_new_package();
		$addons_ids = array(
			$addon1->get_id(),
			$addon2->get_id()
		);

		Wiaas_Package_Addon::set_package_addons($package, $addons_ids);

		$added_addons = Wiaas_Package_Addon::get_package_addons($package);

		$this->assertNotEmpty($added_addons);
		$this->assertCount(2, $added_addons);

		foreach ($added_addons as $added_addon) {
			$this->assertTrue(in_array($added_addon->get_id(), $addons_ids));
		}
	}
}