Commit ac9b3a8a authored by Pieter Frenssen's avatar Pieter Frenssen
Browse files

Test that the correct project names are returned for modules and themes.

parent 32eab7af
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
@@ -115,4 +115,69 @@ class ProjectUnitTest extends \PHPUnit_Framework_TestCase
    }//end coreVersionProvider()


    /**
     * Tests the extending classes Sniff class.
     *
     * @param string $filename    Name of the file that will be checked.
     * @param string $projectname Expected project name for the file.
     *
     * @dataProvider projectNameDetectionProvider
     *
     * @return void
     */
    public function testProjectNameDetection($filename, $projectname)
    {
        $this->phpcsFile->expects($this->any())
            ->method('getFilename')
            ->will($this->returnValue($filename));

        $this->assertEquals(Project::getName($this->phpcsFile), $projectname);

    }//end testProjectNameDetection()


    /**
     * Data provider for testProjectNameDetection().
     *
     * @return array
     *   An array of test cases, each test case an array with two elements:
     *   - The filename to check.
     *   - The expected project name.
     */
    public function projectNameDetectionProvider()
    {
        return [
            [
                __DIR__.'/drupal6/testmodule.info',
                'testmodule',
            ],
            [
                __DIR__.'/drupal6/nested/test.php',
                'testmodule',
            ],
            [
                __DIR__.'/drupal7/testmodule.info',
                'testmodule',
            ],
            [
                __DIR__.'/drupal8/testmodule.info.yml',
                'testmodule',
            ],
            [
                __DIR__.'/drupal8/testtheme/testtheme.info.yml',
                'testtheme',
            ],
            [
                __DIR__.'/drupal8/testtheme/testtheme.theme',
                'testtheme',
            ],
            [
                'invalid',
                false,
            ],
        ];

    }//end projectNameDetectionProvider()


}//end class
+5 −0
Original line number Diff line number Diff line
name: Test Theme
description: A test theme for the DrupalPractice standard.
package: Coder
type: theme
core: 8.x
+5 −0
Original line number Diff line number Diff line
<?php

/**
 * Main functions and hook implementations of the test theme.
 */