This PR moves the JSON API responses used in the tests to fixture files within the tests folder. This allows reuse and the ability to lint/validate these fixtures if required - although not covered in this PR. I've added TestCase::getPsr7StreamForFixture and TestCase::getPsr7JsonResponseForFixture to reduce code duplication and enable some assertions around the expected fixures/responses. Thanks,
35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: junade
|
|
* Date: 05/09/2017
|
|
* Time: 13:50
|
|
*/
|
|
class ConfigurationZoneLockdownTest extends TestCase
|
|
{
|
|
public function testGetArray()
|
|
{
|
|
$configuration = new \Cloudflare\API\Configurations\ZoneLockdown();
|
|
$configuration->addIP('1.2.3.4');
|
|
|
|
$array = $configuration->getArray();
|
|
$this->assertEquals(1, sizeof($array));
|
|
|
|
$this->assertObjectHasAttribute('target', $array[0]);
|
|
$this->assertEquals('ip', $array[0]->target);
|
|
$this->assertObjectHasAttribute('value', $array[0]);
|
|
$this->assertEquals('1.2.3.4', $array[0]->value);
|
|
|
|
$configuration->addIPRange('1.2.3.4/24');
|
|
|
|
$array = $configuration->getArray();
|
|
$this->assertEquals(2, sizeof($array));
|
|
|
|
$this->assertObjectHasAttribute('target', $array[1]);
|
|
$this->assertEquals('ip_range', $array[1]->target);
|
|
$this->assertObjectHasAttribute('value', $array[1]);
|
|
$this->assertEquals('1.2.3.4/24', $array[1]->value);
|
|
}
|
|
}
|