public static function get($url, $options = [], $caller = __METHOD__) { PHPUnit_Framework_Assert::assertInternalType('string', $url); PHPUnit_Framework_Assert::assertInternalType('array', $options); PHPUnit_Framework_Assert::assertInternalType('string', $caller); return self::$response; }
/** * @test */ public function it_can_return_its_id() { $conn = $this->factory->createConnection('localhost'); $channel = $this->factory->createChannel($conn); Assert::assertInternalType('integer', $channel->getChannelId()); Assert::assertGreaterThan(0, $channel->getChannelId()); }
/** * @param string $property * @param string $format * * @return mixed[] */ private function decodeByProperty($property, $format) { return array_map(function ($entry) use($property) { \PHPUnit_Framework_Assert::assertInternalType('array', $entry); \PHPUnit_Framework_Assert::assertArrayHasKey($property, $entry); return $entry[$property]; }, $this->decode($format)); }
/** * Expect that a variable is of a given type. * * @param string $expected * @param string $message * * @return Expect */ public function toBeOfType($expected, $message = '') { Assert::assertInternalType($expected, $this->value, $message); return $this; }
/** * Assert that the data member is a collection, and return it as a resource collection tester. * * @param string|null $message * @return ResourcesTester */ public function assertResourceCollection($message = null) { $message = $message ?: 'Document does not have a resource collection in its data member.'; $collection = $this->getData(); PHPUnit::assertInternalType('array', $collection, $message); return new ResourcesTester($collection); }
/** * @Then the :name property is a(n) :type */ public function thePropertyIsA($name, $type) { $data = $this->getScopedResponse(); PHPUnit::assertInternalType($type, $data->{$name}); }
/** * Asserts if the value retrieved with the expression equals the expected value. * * Example: * * static::assertJsonValueEquals(33, 'foo.bar[0]', $json); * * @param mixed $expected Expected value * @param string $expression Expression to retrieve the result * (e.g. locations[?state == 'WA'].name | sort(@)) * @param array|object $json JSON Content */ public static function assertJsonValueEquals($expected, $expression, $json) { $result = \JmesPath\Env::search($expression, $json); \PHPUnit_Framework_Assert::assertEquals($expected, $result); \PHPUnit_Framework_Assert::assertInternalType(gettype($expected), $result); }
/** * Checks that the property is a passed type. * Either 'int', 'bool', 'string', 'array', 'float', 'null', 'resource', 'scalar' can be passed for simple types. * Otherwise the parameter must be a class and the property must be an instance of that class. * * Bear in mind that testing non-public properties is not a good practice. * Use it only if you have no other way to test it. * * @param $object * @param $property * @param $type * @deprecated */ public function seePropertyIs($object, $property, $type) { $current = $this->retrieveProperty($object, $property); if (in_array($type, array('int', 'bool', 'string', 'array', 'float', 'null', 'resource', 'scalar'))) { \PHPUnit_Framework_Assert::assertInternalType($type, $current); return; } \PHPUnit_Framework_Assert::assertInstanceOf($type, $current); }
/** * @param $type * @param $actual * @param $description */ protected function assertInternalType($type, $actual, $description) { \PHPUnit_Framework_Assert::assertInternalType($type, $actual, $description); }
public function testGetAllChannels() { // Creating response with specific url $this->_clientMockAdapter->addResponseBy(Response::STATUS_OK, 'api/channel', json_encode($this->channelsData)); $repo = new ChannelRepository($this->_client); $metadata = array(); $channels = $repo->getAllRecords(null, $metadata); // Checking response (validating specific url was matched) \PHPUnit_Framework_Assert::assertTrue($this->_client->getResponse()->isOK()); // Check return type \PHPUnit_Framework_Assert::assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $channels); // Check return count \PHPUnit_Framework_Assert::assertEquals(count($this->channelsData['objects']), count($channels)); if ($channels) { // Check return item type \PHPUnit_Framework_Assert::assertInstanceOf(self::MODEL_NAMESPACE . 'Channel', $channels[0]); } // Validating fields data $this->validatesObjectsData($this->channelsData['objects'], $channels); }
/** * @return \stdClass[] */ public function fetchExpenseListsForMyAccount() { $this->client->request('GET', '/expense_list/'); $response = $this->client->getResponse(); PHPUnit_Framework_Assert::assertEquals(Response::HTTP_OK, $response->getStatusCode()); PHPUnit_Framework_Assert::assertJson($response->getContent()); $responseData = json_decode($response->getContent()); PHPUnit_Framework_Assert::assertInternalType('array', $responseData); return $responseData; }
public function isInternalType($type) { Assert::assertInternalType($type, $this->actual, $this->description); return $this; }
public function testJsonDataResponse() { $path = '/test/path'; $headers = array('h1' => 'a', 'h2' => 'b'); $parameters = array('p1' => 'c', 'p2' => 'd'); $method = AbstractClient::METHOD_GET; $responseData = array('status' => 'ok', 'data' => 123, 'message' => 'This is a test'); $responseContent = json_encode($responseData); $mockAdapter = new MockAdapter(); // Adds mock basic OK response $mockAdapter->addResponseBy(Response::STATUS_OK, '', $responseContent); // Add mock adapter $this->_client->setAdapter($mockAdapter); // Send request $data = $this->_client->get($path, $parameters, $headers); // Gets response object $response = $this->_client->getResponse(); // Content is being returned correctly \PHPUnit_Framework_Assert::assertJson($response->getRawContent()); \PHPUnit_Framework_Assert::assertJsonStringEqualsJsonString($responseContent, $response->getRawContent()); // Content is being parsed correctly (json) \PHPUnit_Framework_Assert::assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $data); // Check data parsed foreach ($responseData as $key => $value) { \PHPUnit_Framework_Assert::assertObjectHasAttribute($key, $data); \PHPUnit_Framework_Assert::assertEquals($value, $data->{$key}); } \PHPUnit_Framework_Assert::assertTrue($response->isOK()); }
public function internalType($type) { a::assertInternalType($type, $this->actual, $this->description); }
/** * @Given that I create a new product number */ public function thatICreateANewProductNumber() { $this->new_product_number = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 0, 16); PHPUnit::assertInternalType('string', $this->new_product_number); }
public function toBeType($type) { if ($this->negate) { a::assertNotInternalType($type, $this->actual); } else { a::assertInternalType($type, $this->actual); } }
/** * @Then The response should contain a :key */ public function theResponseShouldContainA($key) { \PHPUnit_Framework_Assert::assertInternalType('array', $this->result); \PHPUnit_Framework_Assert::assertArrayHasKey($key, $this->result); \PHPUnit_Framework_Assert::assertNotEmpty($this->result[$key]); }
/** * Asserts that a variable is of a given type. * * @param string $expected * @param mixed $actual * @param string $message * @since Method available since Release 3.5.0 */ function assertInternalType($expected, $actual, $message = '') { return PHPUnit_Framework_Assert::assertInternalType($expected, $actual, $message); }
/** * @Then the :field property is a boolean * * Checks if the specified field is a boolean * - * Example: * And the "is_released" property is a boolean */ public function thePropertyIsABoolean($property) { $payload = $this->getScopePayload(); PHPUnit::assertInternalType('boolean', $this->arrayGet($payload, $property), sprintf("Asserting the [%s] property in current scope [%s] is a boolean", $property, $this->scope)); }