64 : void
65 {
66 $env = $this->createMock(Setup\Environment::class);
67
68 $mock = $this->getMockBuilder(ClientIdReadObjective::class)
69 ->onlyMethods(["getDataDirectoryPath", "scanDirectory", "isDirectory"])
70 ->getMock();
71
72 $DATA_DIR = "/foo/bar/data";
73 $SOME_DIR = "clientid";
74 $SOME_FILE = "some_file";
75 $SCAN_RESULT = [".", "..", $SOME_DIR, $SOME_FILE];
76
77 $mock
78 ->expects($this->once())
79 ->method("getDataDirectoryPath")
80 ->willReturn($DATA_DIR);
81
82 $mock
83 ->expects($this->once())
84 ->method("scanDirectory")
85 ->with($DATA_DIR)
86 ->willReturn($SCAN_RESULT);
87
88 $consecutive = [
89 [$DATA_DIR . "/" . $SOME_DIR, true],
90 [$DATA_DIR . "/" . $SOME_FILE, false]
91 ];
92 $mock
93 ->expects($this->exactly(2))
94 ->method("isDirectory")
95 ->willReturnCallback(
96 function (
$path) use (&$consecutive):
bool {
97 list($expected, $return) = array_shift($consecutive);
98 $this->assertEquals($expected,
$path);
99 return $return;
100 }
101 );
102
103 $env
104 ->expects($this->once())
105 ->method("withResource")
107 ->willReturn($env);
108
109 $res = $mock->achieve($env);
110 $this->assertSame($env,
$res);
111 }