1616 OperatingSystem ,
1717 Config ,
1818};
19- use Innmind \Filesystem \Adapter ;
20- use Innmind \FileWatch \Watch ;
19+ use Innmind \Server \Control \{
20+ Server ,
21+ Server \Process \Builder ,
22+ };
23+ use Innmind \Filesystem \{
24+ Adapter ,
25+ Directory ,
26+ };
2127use Innmind \Url \Path ;
22- use Innmind \Immutable \Set ;
28+ use Innmind \Immutable \{
29+ Set ,
30+ Attempt ,
31+ };
2332use PHPUnit \Framework \TestCase ;
2433
2534class WatchSourcesTest extends TestCase
@@ -36,10 +45,33 @@ public function testSendMessageWhenSourcesAreModified()
3645 {
3746 $ agent = new WatchSources ;
3847
48+ $ adapter = Adapter::inMemory ();
49+ $ _ = $ adapter
50+ ->add (Directory::named ('src ' ))
51+ ->unwrap ();
52+
53+ $ count = 0 ;
3954 $ os = OperatingSystem::new (
4055 Config::new ()
41- ->mountFilesystemVia (static fn () => Attempt::result (Adapter::inMemory ()))
42- ->useFileWatch (Watch::via ()), // todo simulate file change
56+ ->mountFilesystemVia (static fn () => Attempt::result ($ adapter ))
57+ ->useServerControl (Server::via (
58+ function ($ command ) use (&$ count ) {
59+ $ this ->assertSame (
60+ "find '/vendor/package/src/' '-type' 'f' | xargs '-n' '1' '-r' 'stat' '-f' '%Sm %N' '-t' '%Y-%m-%dT%H-%M-%S' " ,
61+ $ command ->toString (),
62+ );
63+
64+ $ builder = Builder::foreground (2 );
65+ $ builder = match ($ count ) {
66+ 0 => $ builder ->success ([['output ' , 'output ' ]]),
67+ 1 => $ builder ->success ([['changed ' , 'output ' ]]),
68+ 2 => $ builder ->failed (),
69+ };
70+ ++$ count ;
71+
72+ return Attempt::result ($ builder ->build ());
73+ },
74+ )),
4375 );
4476
4577 $ activities = Activities::new (
0 commit comments