2020-04-05 04:35:44 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2020-04-05 05:11:20 +00:00
|
|
|
"sort"
|
2020-04-05 04:35:44 +00:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
const fixtureDirectory = `fixtures`
|
|
|
|
|
|
|
|
func TestConvertFixtures(t *testing.T) {
|
|
|
|
fh, err := os.Open(fixtureDirectory)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer fh.Close()
|
|
|
|
|
|
|
|
fixtures, err := fh.Readdirnames(-1)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-04-05 05:11:20 +00:00
|
|
|
sort.Strings(fixtures)
|
|
|
|
|
2020-04-05 04:35:44 +00:00
|
|
|
for _, fixture := range fixtures {
|
|
|
|
if !strings.HasSuffix(fixture, `.php`) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
ret, err := ConvertFile(filepath.Join(fixtureDirectory, fixture))
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("In test fixture %s:\n %s", fixture, err.Error())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// Success
|
|
|
|
t.Logf("Successful test for fixture %s:\n%s", fixture, ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|