Craft\ImportServiceTest::testPrepForFieldType PHP Method

testPrepForFieldType() public method

Test preparing value for field type.
public testPrepForFieldType ( string $fieldType, string $data, array $settingsMap, string $criteria, string $expectedResult )
$fieldType string
$data string
$settingsMap array
$criteria string
$expectedResult string
    public function testPrepForFieldType($fieldType, $data, array $settingsMap, $criteria, $expectedResult)
    {
        $fieldHandle = 'handle';
        $mockField = $this->getMockBuilder('Craft\\FieldModel')->disableOriginalConstructor()->getMock();
        $mockField->expects($this->any())->method('__get')->willReturnMap(array(array('type', $fieldType)));
        $this->setMockFieldsService($fieldHandle, $mockField);
        if (!empty($settingsMap)) {
            $this->setMockSettings($settingsMap, $mockField);
        }
        if (!empty($criteria)) {
            $this->setMockElementsServiceForFieldType($criteria);
        }
        $service = $this->getMock('Craft\\ImportService', array('getNewTagModel'));
        if ($fieldType == ImportModel::FieldTypeTags) {
            $mockTag = $this->getMockTag();
            $mockTag->expects($this->any())->method('__get')->with('id')->willReturn($expectedResult[0]);
            $this->setMockTagsService($mockTag);
            $service->expects($this->any())->method('getNewTagModel')->willReturn($mockTag);
        }
        if ($fieldType == ImportModel::FieldTypeCategories) {
            $this->setMockCategoriesService();
        }
        $result = $service->prepForFieldType($data, $fieldHandle);
        $this->assertEquals($expectedResult, $result);
    }