Skip to content

Commit 9282a88

Browse files
Takashi Matsuobshaffer
authored andcommitted
Fixes a few tests
1 parent 95a57d5 commit 9282a88

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

appengine/flexible/metadata/test/DeployTest.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
namespace Google\Cloud\Samples\AppEngine\Datastore;
17+
namespace Google\Cloud\Samples\AppEngine\Metadata;
1818

1919
use Google\Cloud\TestUtils\AppEngineDeploymentTrait;
2020

@@ -24,27 +24,23 @@ class DeployTest extends \PHPUnit_Framework_TestCase
2424

2525
public function testIndex()
2626
{
27-
$client = $this->createClient();
27+
$resp = $this->client->get('/');
2828

29-
$crawler = $client->request('GET', '/');
30-
31-
$this->assertTrue($client->getResponse()->isOk());
32-
$this->assertRegExp(
33-
'/External IP: .*/',
34-
$client->getResponse()->getBody()
35-
);
29+
$this->assertEquals(
30+
'200',
31+
$resp->getStatusCode(),
32+
'Top page status code should be 200');
33+
$this->assertRegExp('/External IP: .*/', (string) $resp->getBody());
3634
}
3735

3836
public function testCurl()
3937
{
40-
$client = $this->createClient();
41-
42-
$crawler = $client->request('GET', '/curl');
38+
$resp = $this->client->get('/curl');
4339

44-
$this->assertTrue($client->getResponse()->isOk());
45-
$this->assertRegExp(
46-
'/External IP: .*/',
47-
$client->getResponse()->getBody()
48-
);
40+
$this->assertEquals(
41+
'200',
42+
$resp->getStatusCode(),
43+
'/curl status code should be 200');
44+
$this->assertRegExp('/External IP: .*/', (string) $resp->getBody());
4945
}
5046
}

datastore/tutorial/test/FunctionsTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ public function testListTasks()
8989
$result = list_tasks(self::$datastore);
9090
$found = 0;
9191
foreach ($result as $task) {
92-
$this->assertEquals('buy milk', $task['description']);
93-
$this->assertInstanceOf(
94-
\DateTimeInterface::class,
95-
$task['created']
96-
);
97-
$this->assertEquals(false, $task['done']);
98-
$this->assertEquals('buy milk', $task['description']);
99-
$this->assertArrayHasKey('id', $task->key()->pathEnd());
100-
$found += 1;
92+
if ($task['description'] === 'buy milk') {
93+
$this->assertInstanceOf(
94+
\DateTimeInterface::class,
95+
$task['created']
96+
);
97+
$this->assertEquals(false, $task['done']);
98+
$this->assertArrayHasKey('id', $task->key()->pathEnd());
99+
$found += 1;
100+
}
101101
}
102-
$this->assertEquals(1, $found);
102+
$this->assertEquals(1, $found, 'It should list a new task.');
103103
});
104104
}
105105

kms/api/test/KeyCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ public function setUp()
3232
if (!$projectId = getenv('GOOGLE_PROJECT_ID')) {
3333
return $this->markTestSkipped('Set the GOOGLE_PROJECT_ID environment variable');
3434
}
35-
35+
if (!$ring = getenv('GOOGLE_KMS_KEYRING')) {
36+
return $this->markTestSkipped('Set the GOOGLE_KMS_KEYRING environment variable');
37+
}
3638
$this->projectId = $projectId;
37-
$this->ring = getenv('GOOGLE_KMS_KEYRING');
39+
$this->ring = $ring;
3840
$application = new Application();
3941
$application->add(new KeyCommand());
4042
$this->commandTester = new CommandTester($application->get('key'));

0 commit comments

Comments
 (0)