Results: 1022
check if the key exists in the response JSON
Tests that key
text
exists in the response JSON
pm.test("status text key exists", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.status.text !== undefined).to.eql(true);
});
The response JSON
{
    "status": {
        "code": 400,
        "text": "Mobile Number is required"
    }
}
check the response JSON key value
Tests that the value of
code
key is equal to
400
pm.test("status code is equal to invalid HTTP request", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.status.code).to.eql(400);
});
The response JSON
{
    "status": {
        "code": 400,
        "text": "Mobile Number is required"
    }
}
set and get environment variables
Set an environment variable
allowedMilliseconds
with value
100
pm.environment.set("allowedMilliseconds", 100);
Get the environment variable
pm.environment.get("allowedMilliseconds")
The environment variable in real use case. In this example response time is checked to be below 100ms
pm.test("Response time is less than "+pm.environment.get("allowedMilliseconds")+"ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(pm.environment.get("allowedMilliseconds"));
});
set and get global variables
Set an global variable
allowedMilliseconds
with value
100
pm.global.set("allowedMilliseconds", 100);
Get the global variable
pm.global.get("allowedMilliseconds")
The global variable in real use case. In this example response time is checked to be below 100ms
pm.test("Response time is less than "+pm.global.get("allowedMilliseconds")+"ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(pm.global.get("allowedMilliseconds"));
});
call JS function ("this" context)
Here
this
means the object being clicked
<a class="view_all" onclick="consoleLogMe(this);" href="javascript:">object being clicked</a>
this
means the global object
window
in this example:
<a class="view_all" href="javascript:alertMe(this)">window object</a> 
passing PHP values to JS in Laravel blade
Correct way to pass values to
JS
is to use
!!
directives:
<script>
        
    change_asset_category('{!! $category_values !!}');

</script>
The result will be:
<script>
        
change_asset_category('{"version":"vers","patch_level":"patc","bcp_dr":"bcp\/d"}');

</script>
There are two the most commonly used Encoding Types for XML documents: 1.
UTF-8
- 8-bits are used to represent a character 2.
UTF-16
- 16-bits are used to represent a character ...
UTF
stands for
UCS Transformation Format
, and UCS itself means
Universal Character Set
... XML document example that has
UTF-8
encoding
<?xml version="1.0" encoding="UTF-8"?>
<student>
    <first-name>George</first-name>
    <phone.mobile>(011) 123-4567</phone.mobile>
</student>
Note: If an XML document has not specified encoding, the default is
UTF-8
XML - get PI's values using PHP
The code below can be used to get PI's value from an XML document
<?php

$my_xml_data = 
'<?xml version="1.0" encoding="UTF-8"?>
<student>
    <?sort alpha-ascending?>
    <?textinfo whitespace is allowed ?>
    <first-name>George</first-name>
    <phone.mobile>(011) 123-4567</phone.mobile>
</student>';

$xml = simplexml_load_string($my_xml_data);

$doc   = dom_import_simplexml($xml)->ownerDocument;
$xpath = new DOMXPath($doc);

# prints "/* processing instructions */ ", the value of the first PI: textinfo
echo $xpath->evaluate('string(//processing-instruction("textinfo")[1])');
The output of the above code is the following:
whitespace is allowed
XML comments
Similar to HTML comments, XML comment has the following syntax:
<!-- Our comment -->
XML comment example in XML document:
<?xml version="1.0" encoding="UTF-8"?>
<student>
    <!-- Some comment about the student -->
    <first-name>George</first-name>
    <phone.mobile>(011) 123-4567</phone.mobile>
    <tive_language>English</tive_language>
    <another_tag>some text</another_tag>
    <city />
</student>
XML empty tags
An empty element in XML document can be represented in two ways:
<?xml version="1.0" encoding="UTF-8"?>
<student>
   <name>George</name>
   <phone>(011) 123-4567</phone>
   <address></address>
   <city />
</student>
One way is
<address></address>
element and another is
<city />
. In other words, one with closing tag and another is self-closing tag.
Results: 1022