test/unit/WindowsPrintConnectorTest.php
/**
     * Test for correct identification of bogus or non-supported Samba strings.
     */
Test for correct identification of bogus or non-supported Samba strings.
Test for correct identification of bogus or non - supported Samba strings .
public function testSambaRegex()
    {
        $good = array("smb://foo/bar",
                "smb://foo/bar baz",
                "smb://bob@foo/bar",
                "smb://bob:secret@foo/bar",
                "smb://foo-computer/FooPrinter",
                "smb://foo-computer/workgroup/FooPrinter",
                "smb://foo-computer/Foo-Printer",
                "smb://foo-computer/workgroup/Foo-Printer",
                "smb://foo-computer/Foo Printer",
                "smb://foo-computer.local/Foo Printer",
                "smb://127.0.0.1/abcd"
        );
        $bad = array("",
                "http://google.com",
                "smb:/foo/bar",
                "smb://",
                "smb:///bar",
                "smb://@foo/bar",
                "smb://bob:@foo/bar",
                "smb://:secret@foo/bar",
                "smb://foo/bar/baz/quux",
                "smb://foo-computer//FooPrinter");
        foreach ($good as $item) {
            $this -> assertTrue(preg_match(WindowsPrintConnector::REGEX_SMB, $item) == 1, "Windows samba regex should pass '$item'.");
        }
        foreach ($bad as $item) {
            $this -> assertTrue(preg_match(WindowsPrintConnector::REGEX_SMB, $item) != 1, "Windows samba regex should fail '$item'.");
        }
    }
public function testSambaRegex ( ) { $ good = array ( " smb://foo/bar " , " smb://foo/bar baz " , " smb://bob@foo/bar " , " smb://bob:secret@foo/bar " , " smb://foo-computer/FooPrinter " , " smb://foo-computer/workgroup/FooPrinter " , " smb://foo-computer/Foo-Printer " , " smb://foo-computer/workgroup/Foo-Printer " , " smb://foo-computer/Foo Printer " , " smb://foo-computer.local/Foo Printer " , " smb://127.0.0.1/abcd " ) ; $ bad = array ( " " , " http://google.com " , " smb:/foo/bar " , " smb:// " , " smb:///bar " , " smb://@foo/bar " , " smb://bob:@foo/bar " , " smb://:secret@foo/bar " , " smb://foo/bar/baz/quux " , " smb://foo-computer//FooPrinter " ) ; foreach ( $ good as $ item ) { $ this -> assertTrue ( preg_match ( WindowsPrintConnector :: REGEX_SMB , $ item ) == 1 , " Windows samba regex should pass ' $ item '. " ) ; } foreach ( $ bad as $ item ) { $ this -> assertTrue ( preg_match ( WindowsPrintConnector :: REGEX_SMB , $ item ) != 1 , " Windows samba regex should fail ' $ item '. " ) ; } }
Test for correct identification of bogus or non-supported Samba strings.
Test for correct identification of bogus or non - supported Samba strings .