public function testGetCategories() { $itemProphecy1 = $this->prophesize('\\core_kernel_classes_Resource'); $itemProphecy2 = $this->prophesize('\\core_kernel_classes_Resource'); $itemProphecy3 = $this->prophesize('\\core_kernel_classes_Resource'); $itemProphecy4 = $this->prophesize('\\core_kernel_classes_Resource'); $itemProphecy5 = $this->prophesize('\\core_kernel_classes_Resource'); $properties = array('subject', 'difficulty'); $item1Properties = array('subject' => array(new \core_kernel_classes_Resource('science'), new \core_kernel_classes_Literal('math')), 'difficulty' => array(new \core_kernel_classes_Resource('http://tao.test/mytao.rdf#semi'))); $item2Properties = array('subject' => array(new \core_kernel_classes_Resource('http://tao.test/mytao.rdf#ELA'))); $item3Properties = array('subject' => array(new \core_kernel_classes_Literal('math')), 'difficulty' => array(new \core_kernel_classes_Literal('easy'))); $item4Properties = array(); $item5Properties = array('subject' => array(new \core_kernel_classes_Resource('http://tao.test/mytao.rdf#ELA')), 'difficulty' => array(new \core_kernel_classes_Literal('hard'))); $itemProphecy1->getPropertiesValues($properties)->willReturn($item1Properties); $itemProphecy1->getUri()->willReturn('itemUri1'); $itemProphecy2->getPropertiesValues($properties)->willReturn($item2Properties); $itemProphecy2->getUri()->willReturn('itemUri2'); $itemProphecy3->getPropertiesValues($properties)->willReturn($item3Properties); $itemProphecy3->getUri()->willReturn('itemUri3'); $itemProphecy4->getPropertiesValues($properties)->willReturn($item4Properties); $itemProphecy4->getUri()->willReturn('itemUri4'); $itemProphecy5->getPropertiesValues($properties)->willReturn($item5Properties); $itemProphecy5->getUri()->willReturn('itemUri5'); $items = array($itemProphecy1->reveal(), $itemProphecy5->reveal(), $itemProphecy3->reveal(), $itemProphecy4->reveal(), $itemProphecy2->reveal()); $expected = array('itemUri1' => array('SCIENCE', 'MATH', 'MEDIUM'), 'itemUri5' => array('ENGLISH', 'HIGH'), 'itemUri3' => array('MATH', 'LOW'), 'itemUri4' => array(), 'itemUri2' => array('ENGLISH')); /** @var ItemCategoriesService $itemCategoriesService */ $itemCategoriesService = new ItemCategoriesService(array('properties' => array('subject' => array('math' => 'MATH', 'http://tao.test/mytao.rdf#ELA' => 'ENGLISH', 'science' => 'SCIENCE'), 'difficulty' => array('easy' => 'LOW', 'http://tao.test/mytao.rdf#semi' => 'MEDIUM', 'hard' => 'HIGH')))); $categories = $itemCategoriesService->getCategories($items); $this->assertEquals($expected, $categories); }