/**
  * @param NodeInterface|null $node
  * @param array $arguments
  * @return \TYPO3\Flow\Persistence\QueryResultInterface
  */
 public function getData(NodeInterface $node = null, array $arguments)
 {
     $formDefinitions['']['label'] = '';
     $forms = $this->yamlPersistenceManager->listForms();
     foreach ($forms as $form) {
         $formDefinitions[$form['identifier']]['label'] = $form['name'];
     }
     return $formDefinitions;
 }
 public function setUp()
 {
     $this->submissionService = $this->getAccessibleMock('GIB\\GradingTool\\Service\\SubmissionService', array('dummy'), array(), '', FALSE);
     // get a yaml persistence manager
     $this->yamlPersistenceManager = new \TYPO3\Form\Persistence\YamlPersistenceManager();
     vfsStream::setup('someSavePath');
     $yamlPersistenceManagerSettings = array('yamlPersistenceManager' => array('savePath' => vfsStream::url('someSavePath')));
     $this->yamlPersistenceManager->injectSettings($yamlPersistenceManagerSettings);
     // write a mock submission form
     $mockYamlFormDefinition = "type: 'TYPO3.Form:Form'\nidentifier: mockSubmissionForm\nlabel: 'Mock Submission Form'\nrenderables:\n    -\n        type: 'TYPO3.Form:Page'\n        identifier: accountability\n        label: Accountability\n        renderables:\n            -\n                type: 'TYPO3.Form:Section'\n                identifier: sectionAccountability\n                label: Accountability\n                properties:\n                    elementClass: hideCaption\n                    displayConditionField: ''\n                    displayConditionValue: ''\n                    goodPerformanceReferenceScore: '3.6'\n                    modestPerformanceReferenceScore: '2.7'\n                    naAcceptanceLevel: '0.2'\n                renderables:\n                    -\n                        type: 'GIB.GradingTool:Question'\n                        identifier: accountability1\n                        label: '1.) Does this project have a clear organisational setup?'\n                        validators:\n                            -\n                                identifier: 'TYPO3.Flow:NotEmpty'\n                        properties:\n                            options:\n                                -\n                                    _value: 'The organisational structure of service provision makes no distinction between different roles such as strategic level (board), execution (management), oversight, arbitration (e.g. for consumer claims) etc.'\n                                    _key: '1'\n                                    score: '1'\n                                -\n                                    _value: 'Different bodies are in place and roles are separated but it is not adequate due to incompleteness of staffing, institutional overlaps, or overlapping or missing competencies, etc.'\n                                    _key: '2'\n                                    score: '2'\n                                -\n                                    _value: 'The organisational structure and role separation are in place, but the interaction between the bodies/actors does not function all the time.'\n                                    _key: '3'\n                                    score: '3'\n                                -\n                                    _value: 'An organisational structure is in place with clear role separation (separation of board and management, oversight, arbitration etc.), unambiguous allocation of responsibilities and duties. Proper interaction between actors are clearly defined and function effectively.'\n                                    _key: '4'\n                                    score: '4'\n                                -\n                                    _value: 'Not applicable/other'\n                                    _key: '5'\n                                    score: '0'\n                            weighting: '1'\n                            optOut: '0'\n                            abstract: 'Clear organisational setup'\n    -\n        type: 'TYPO3.Form:Page'\n        identifier: transparency\n        label: Transparency\n        renderables:\n            -\n                type: 'TYPO3.Form:Section'\n                identifier: sectionTransparency\n                label: Transparency\n                properties:\n                    elementClass: hideCaption\n                    displayConditionField: ''\n                    displayConditionValue: ''\n                    goodPerformanceReferenceScore: '3.6'\n                    modestPerformanceReferenceScore: '2.5'\n                    naAcceptanceLevel: '0.2'\n                renderables:\n                    -\n                        type: 'GIB.GradingTool:Question'\n                        identifier: transparency1\n                        label: '1.) How is public access to information concerning the project for the public organised?'\n                        validators:\n                            -\n                                identifier: 'TYPO3.Flow:NotEmpty'\n                        properties:\n                            options:\n                                -\n                                    _value: 'There is no clear guidance/regulation that defines which documents (e.g. reports, studies or contracts) are publicly available, whether at local or national level.'\n                                    _key: '1'\n                                    score: '1'\n                                -\n                                    _value: 'Access to information requires substantial effort and persistence. Information is usually provided selectively.'\n                                    _key: '2'\n                                    score: '2'\n                                -\n                                    _value: 'All relevant documents are available to the public on demand (e.g. via written request and/or payment for service).'\n                                    _key: '3'\n                                    score: '3'\n                                -\n                                    _value: 'All relevant documents are available. There is a written policy in place and contracts contain defined transparency requirements; financing of those activities is clarified.'\n                                    _key: '4'\n                                    score: '4'\n                                -\n                                    _value: 'Not applicable/other'\n                                    _key: '5'\n                                    score: '0'\n                            weighting: '1'\n                            optOut: '0'\n                            abstract: 'Public access to information'\n    -\n        type: 'TYPO3.Form:Page'\n        identifier: customerFocus\n        label: 'Customer Focus'\n        renderables:\n            -\n                type: 'TYPO3.Form:Section'\n                identifier: sectionCustomerFocus\n                label: 'Customer Focus'\n                properties:\n                    elementClass: hideCaption\n                    displayConditionField: ''\n                    displayConditionValue: ''\n                    goodPerformanceReferenceScore: '3.4'\n                    modestPerformanceReferenceScore: '2.1'\n                    naAcceptanceLevel: '0.3'\n                renderables:\n                    -\n                        type: 'GIB.GradingTool:Question'\n                        identifier: customerFocus1\n                        label: '1.) Will the provided services justify the usage fees?'\n                        validators:\n                            -\n                                identifier: 'TYPO3.Flow:NotEmpty'\n                        properties:\n                            options:\n                                -\n                                    _value: 'No, there will constantly be a significant gap: services will be far from adequate given the charges.'\n                                    _key: '1'\n                                    score: '1'\n                                -\n                                    _value: 'The service will not be able to guarantee continuity due to market uncertainty such as the fluctuation of raw materials and local market dynamism. The tariff would be reasonable if the service were continuous and good.'\n                                    _key: '2'\n                                    score: '2'\n                                -\n                                    _value: 'The service level and the charges will largely be justified.'\n                                    _key: '3'\n                                    score: '3'\n                                -\n                                    _value: 'The project has undergone careful study and scientific analysis. All possible factors on pricing and consumer affordability and expectation will be taken into account. The service quality rendered will justify the service charge in a sustainable manner.'\n                                    _key: '4'\n                                    score: '4'\n                                -\n                                    _value: 'Not applicable/other'\n                                    _key: '5'\n                                    score: '0'\n                            weighting: '1'\n                            optOut: '1'\n                            abstract: 'Reasonable service charges'\n                    -\n                        type: 'GIB.GradingTool:NotApplicableMultiLineText'\n                        identifier: customerFocusComment1\n                        label: Comment\n                        properties:\n                            placeholder: ''\n                            questionIdentifier: customerFocus1\n                        defaultValue: ''\n                    -\n                        type: 'GIB.GradingTool:OptOutAcceptedCheckbox'\n                        identifier: customerFocusOptOutAccepted1\n                        label: 'Opt-out accepted'\n                        properties:\n                            questionIdentifier: customerFocus1\n                    -\n                        type: 'GIB.GradingTool:Question'\n                        identifier: customerFocus2\n                        label: '2.) Does the project allow its users to be informed of all relevant rights and obligations?'\n                        validators:\n                            -\n                                identifier: 'TYPO3.Flow:NotEmpty'\n                        properties:\n                            options:\n                                -\n                                    _value: 'No special attempts are made to figure out the details of the relation between service provider and customer; service users are not seen as customers.'\n                                    _key: '1'\n                                    score: '1'\n                                -\n                                    _value: 'The majority of customers do not know their rights and obligations.'\n                                    _key: '2'\n                                    score: '2'\n                                -\n                                    _value: 'A customer charter exists and is communicated.'\n                                    _key: '3'\n                                    score: '3'\n                                -\n                                    _value: 'Satisfaction of customers and stakeholders is pursued throughout the project life cycle. Strategic and systematic customer care and stakeholder relations management is integrated into the project process management.'\n                                    _key: '4'\n                                    score: '4'\n                                -\n                                    _value: 'Not applicable/other'\n                                    _key: '5'\n                                    score: '0'\n                            weighting: '1'\n                            optOut: '0'\n                            abstract: 'Transparency of roles and responsabilities'\n                    -\n                        type: 'GIB.GradingTool:Question'\n                        identifier: customerFocus3\n                        label: '3.) To what extent will customer-friendly complaint procedures exist and how will they be implemented/communicated?'\n                        validators:\n                            -\n                                identifier: 'TYPO3.Flow:NotEmpty'\n                        properties:\n                            options:\n                                -\n                                    _value: 'No formal complaint procedures will exist.'\n                                    _key: '1'\n                                    score: '1'\n                                -\n                                    _value: 'Complaint procedures will exist but they will not be customer friendly (e.g. no customer care centre, complaints only possible through court system).'\n                                    _key: '2'\n                                    score: '2'\n                                -\n                                    _value: 'Complaint procedures will exist and they will be easily accessible, but complaints without ready solutions will not be further followed up.'\n                                    _key: '3'\n                                    score: '3'\n                                -\n                                    _value: 'Customer complaint procedures will be publicly announced and the process of filing a complaint will be easy for all customer groups. Complaints will be taken seriously and addressed in reasonable amount of time.'\n                                    _key: '4'\n                                    score: '4'\n                                -\n                                    _value: 'Not applicable/other'\n                                    _key: '5'\n                                    score: '0'\n                            weighting: '1'\n                            optOut: '0'\n                            abstract: 'Customer-friendly complaint procedure'\n                    -\n                        type: 'GIB.GradingTool:Question'\n                        identifier: customerFocus4\n                        label: '4.) How comprehensible will the invoices/bills be presented to customers and the related tariff systems?'\n                        validators:\n                            -\n                                identifier: 'TYPO3.Flow:NotEmpty'\n                        properties:\n                            options:\n                                -\n                                    _value: 'The bill with the services charged will not inform about details of the calculation and / or the tariff system will not be understandable to ordinary customers.'\n                                    _key: '1'\n                                    score: '1'\n                                -\n                                    _value: 'The bill will merely present a summary of charges with no explanations.'\n                                    _key: '2'\n                                    score: '2'\n                                -\n                                    _value: 'The tariff system will be clear and traceable and the bill will also reflect the tariff system.'\n                                    _key: '3'\n                                    score: '3'\n                                -\n                                    _value: 'The tariff system will be clear and traceable and the bill will also reflect the impacts of the tariff system. Obtaining additional information will be straightforward.'\n                                    _key: '4'\n                                    score: '4'\n                                -\n                                    _value: 'Not applicable/other'\n                                    _key: '5'\n                                    score: '0'\n                            weighting: '1'\n                            optOut: '1'\n                            abstract: 'Comprehensible tariffs and bills'\n                    -\n                        type: 'GIB.GradingTool:NotApplicableMultiLineText'\n                        identifier: customerFocusComment4\n                        label: Comment\n                        properties:\n                            placeholder: ''\n                            questionIdentifier: customerFocus4\n                        defaultValue: ''\n                    -\n                        type: 'GIB.GradingTool:OptOutAcceptedCheckbox'\n                        identifier: customerFocusOptOutAccepted4\n                        label: 'Opt-out accepted'\n                        properties:\n                            questionIdentifier: customerFocus4";
     file_put_contents(vfsStream::url('someSavePath/mockSubmissionForm.yaml'), $mockYamlFormDefinition);
     $this->submissionService->_set('formPersistenceManager', $this->yamlPersistenceManager);
     $gradingToolSettings = array('forms' => array('submission' => 'mockSubmissionForm'));
     $this->submissionService->_set('settings', $gradingToolSettings);
 }
    /**
     * @test
     */
    public function listFormsReturnsAvailableForms()
    {
        $mockYamlFormDefinition1 = 'type: \'TYPO3.Form:Form\'
identifier: formFixture1
label: \'Form Fixture1\'
';
        $mockYamlFormDefinition2 = 'type: \'TYPO3.Form:Form\'
identifier: formFixture2
label: \'Form Fixture2\'
';
        file_put_contents(vfsStream::url('someSavePath/mockForm1.yaml'), $mockYamlFormDefinition1);
        file_put_contents(vfsStream::url('someSavePath/mockForm2.yaml'), $mockYamlFormDefinition2);
        file_put_contents(vfsStream::url('someSavePath/noForm.txt'), 'this should be skipped');
        $expectedResult = array(array('identifier' => 'formFixture1', 'name' => 'Form Fixture1', 'persistenceIdentifier' => 'mockForm1'), array('identifier' => 'formFixture2', 'name' => 'Form Fixture2', 'persistenceIdentifier' => 'mockForm2'));
        $this->assertEquals($expectedResult, $this->yamlPersistenceManager->listForms());
    }