11
11
12
12
namespace FFI \Headers \Bass \Tests ;
13
13
14
- use FFI \Env \Runtime ;
15
14
use FFI \Headers \Bass ;
16
15
use FFI \Headers \Bass \Platform ;
17
- use FFI \Headers \Bass \Tests \BinaryCompatibilityTestCase \Downloader ;
18
16
use FFI \Headers \Bass \Version ;
17
+ use FFI \Headers \Testing \Downloader ;
19
18
20
- /**
21
- * @requires extension ffi
22
- */
23
19
class BinaryCompatibilityTestCase extends TestCase
24
20
{
25
- public function setUp ( ): void
21
+ private function skipIfPlatformNotSupported ( Version $ version , Platform $ platform ): void
26
22
{
27
- if (!Runtime:: isAvailable ( )) {
28
- $ this ->markTestSkipped (' An ext-ffi extension must be available and enabled ' );
23
+ if (!$ version -> supportedOn ( $ platform )) {
24
+ $ this ->markTestSkipped ($ platform -> name . ' not supported by version ' . $ version -> toString () );
29
25
}
30
-
31
- parent ::setUp ();
32
26
}
33
27
34
28
/**
@@ -37,23 +31,16 @@ public function setUp(): void
37
31
*/
38
32
public function testLinuxBinaryCompatibility (Version $ version ): void
39
33
{
40
- if (!$ version ->supportedOn (Platform::LINUX )) {
41
- $ this ->markTestSkipped ('Linux not supported by version ' . $ version ->toString ());
42
- }
43
-
44
- $ binary = __DIR__ . '/storage/libbass- ' . $ version ->toString () . '.so ' ;
34
+ $ this ->skipIfPlatformNotSupported ($ version , Platform::LINUX );
45
35
46
- if (!\is_file ($ binary )) {
47
- Downloader::download ('https://www.un4seen.com/files/bass%s-linux.zip ' , [
36
+ if (!\is_file ($ binary = __DIR__ . ' /storage/libbass- ' . $ version -> toString () . ' .so ' )) {
37
+ Downloader::zip ('https://www.un4seen.com/files/bass%s-linux.zip ' , [
48
38
\str_replace ('. ' , '' , $ version ->toString ()),
49
39
])
50
40
->extract ('x64/libbass.so ' , $ binary );
51
41
}
52
42
53
- $ this ->expectNotToPerformAssertions ();
54
- $ headers = (string )Bass::create (Platform::LINUX , $ version );
55
-
56
- \FFI ::cdef ($ headers , $ binary );
43
+ $ this ->assertHeadersCompatibleWith (Bass::create (Platform::LINUX , $ version ), $ binary );
57
44
}
58
45
59
46
/**
@@ -62,10 +49,8 @@ public function testLinuxBinaryCompatibility(Version $version): void
62
49
*/
63
50
public function testWindowsBinaryCompatibility (Version $ version ): void
64
51
{
65
- $ binary = __DIR__ . '/storage/bass- ' . $ version ->toString () . '.dll ' ;
66
-
67
- if (!\is_file ($ binary )) {
68
- $ result = Downloader::download ('https://www.un4seen.com/files/bass%s.zip ' , [
52
+ if (!\is_file ($ binary = __DIR__ . '/storage/bass- ' . $ version ->toString () . '.dll ' )) {
53
+ $ result = Downloader::zip ('https://www.un4seen.com/files/bass%s.zip ' , [
69
54
\str_replace ('. ' , '' , $ version ->toString ()),
70
55
]);
71
56
@@ -80,10 +65,7 @@ public function testWindowsBinaryCompatibility(Version $version): void
80
65
}
81
66
}
82
67
83
- $ this ->expectNotToPerformAssertions ();
84
- $ headers = (string )Bass::create (Platform::WINDOWS , $ version );
85
-
86
- \FFI ::cdef ($ headers , $ binary );
68
+ $ this ->assertHeadersCompatibleWith (Bass::create (Platform::WINDOWS , $ version ), $ binary );
87
69
}
88
70
89
71
/**
@@ -92,14 +74,10 @@ public function testWindowsBinaryCompatibility(Version $version): void
92
74
*/
93
75
public function testDarwinBinaryCompatibility (Version $ version ): void
94
76
{
95
- if (!$ version ->supportedOn (Platform::DARWIN )) {
96
- $ this ->markTestSkipped ('OSX not supported by version ' . $ version ->toString ());
97
- }
77
+ $ this ->skipIfPlatformNotSupported ($ version , Platform::DARWIN );
98
78
99
- $ binary = __DIR__ . '/storage/libbass- ' . $ version ->toString () . '.dylib ' ;
100
-
101
- if (!\is_file ($ binary )) {
102
- $ result = Downloader::download ('https://www.un4seen.com/files/bass%s-osx.zip ' , [
79
+ if (!\is_file ($ binary = __DIR__ . '/storage/libbass- ' . $ version ->toString () . '.dylib ' )) {
80
+ $ result = Downloader::zip ('https://www.un4seen.com/files/bass%s-osx.zip ' , [
103
81
\str_replace ('. ' , '' , $ version ->toString ()),
104
82
]);
105
83
@@ -114,9 +92,6 @@ public function testDarwinBinaryCompatibility(Version $version): void
114
92
}
115
93
}
116
94
117
- $ this ->expectNotToPerformAssertions ();
118
- $ headers = (string )Bass::create (Platform::DARWIN , $ version );
119
-
120
- \FFI ::cdef ($ headers , $ binary );
95
+ $ this ->assertHeadersCompatibleWith (Bass::create (Platform::DARWIN , $ version ), $ binary );
121
96
}
122
97
}
0 commit comments