-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add .editorconfig to have a consistent code style
- Loading branch information
Showing
3 changed files
with
146 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# EditorConfig: http://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,97 +6,110 @@ | |
|
||
final class Iugu_CustomerTest extends TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
Iugu::$endpoint = 'http://api.desenvolvimento'; | ||
Iugu::setApiKey('development_api_token'); | ||
} | ||
|
||
public function testShouldCreateACustomer() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette('iugu_customer_should_create_a_customer'); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => "[email protected]", | ||
"name" => "Martin Fowler", | ||
"notes" => "Uses emacs" | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals('[email protected]', $customer->email); | ||
$this->assertEquals('Martin Fowler', $customer->name); | ||
$this->assertEquals('Uses emacs', $customer->notes); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
|
||
public function testShouldCreateACustomerWithCPF() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette('iugu_customer_should_create_a_customer_with_cpf'); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => "[email protected]", | ||
"name" => "Martin Fowler", | ||
"cpf_cnpj" => '648.144.103-01' | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals('648.144.103-01', $customer->cpf_cnpj); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
|
||
public function testShouldCreateACustomerWithCNPJ() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette('iugu_customer_should_create_a_customer_with_cnpj'); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => "[email protected]", | ||
"name" => "Martin Fowler Inc", | ||
"cpf_cnpj" => '57.202.023/6256-27' | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals($customer->cpf_cnpj, '57.202.023/6256-27'); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
|
||
public function testShouldCreateACustomerWithFullAddress() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette('iugu_customer_should_create_a_customer_with_full_address'); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => '[email protected]', | ||
"name" => 'John Snow', | ||
"cpf_cnpj" => '648.144.103-01', | ||
"cc_emails" => '[email protected]', | ||
"zip_code" => '29190560', | ||
"number" => '8', | ||
"street" => 'Rua dos Bobos', | ||
"city" => 'São Paulo', | ||
"state" => 'SP', | ||
"district" => 'Mooca', | ||
"complement" => '123C' | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals('648.144.103-01', $customer->cpf_cnpj); | ||
$this->assertEquals('[email protected]', $customer->cc_emails); | ||
$this->assertEquals('29190560', $customer->zip_code); | ||
$this->assertEquals('8', $customer->number); | ||
$this->assertEquals('Rua dos Bobos', $customer->street); | ||
$this->assertEquals('Mooca', $customer->district); | ||
$this->assertEquals('123C', $customer->complement); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
protected function setUp() | ||
{ | ||
Iugu::$endpoint = "http://api.desenvolvimento"; | ||
Iugu::setApiKey("development_api_token"); | ||
} | ||
|
||
public function testShouldCreateACustomer() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette("iugu_customer_should_create_a_customer"); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => "[email protected]", | ||
"name" => "Martin Fowler", | ||
"notes" => "Uses emacs" | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals("[email protected]", $customer->email); | ||
$this->assertEquals("Martin Fowler", $customer->name); | ||
$this->assertEquals("Uses emacs", $customer->notes); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
|
||
public function testShouldCreateACustomerWithCPF() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette("iugu_customer_should_create_a_customer_with_cpf"); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => "[email protected]", | ||
"name" => "Martin Fowler", | ||
"cpf_cnpj" => "648.144.103-01" | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals("648.144.103-01", $customer->cpf_cnpj); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
|
||
public function testShouldCreateACustomerWithCNPJ() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette("iugu_customer_should_create_a_customer_with_cnpj"); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => "[email protected]", | ||
"name" => "Martin Fowler Inc", | ||
"cpf_cnpj" => "57.202.023/6256-27" | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals($customer->cpf_cnpj, "57.202.023/6256-27"); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
|
||
public function testShouldCreateACustomerWithFullAddress() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette("iugu_customer_should_create_a_customer_with_full_address"); | ||
|
||
$customer = Iugu_Customer::create([ | ||
"email" => "[email protected]", | ||
"name" => "John Snow", | ||
"cpf_cnpj" => "648.144.103-01", | ||
"cc_emails" => "[email protected]", | ||
"zip_code" => "29190560", | ||
"number" => "8", | ||
"street" => "Rua dos Bobos", | ||
"city" => "São Paulo", | ||
"state" => "SP", | ||
"district" => "Mooca", | ||
"complement" => "123C" | ||
]); | ||
|
||
$this->assertFalse($customer->is_new()); | ||
$this->assertEquals("648.144.103-01", $customer->cpf_cnpj); | ||
$this->assertEquals("[email protected]", $customer->cc_emails); | ||
$this->assertEquals("29190560", $customer->zip_code); | ||
$this->assertEquals("8", $customer->number); | ||
$this->assertEquals("Rua dos Bobos", $customer->street); | ||
$this->assertEquals("Mooca", $customer->district); | ||
$this->assertEquals("123C", $customer->complement); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
|
||
public function testShouldRaiseErrorWhenEmailIsEmpty() | ||
{ | ||
\VCR\VCR::turnOn(); | ||
\VCR\VCR::insertCassette("iugu_customer_should_not_create_a_customer_without_email"); | ||
|
||
$customer = Iugu_Customer::create(["name" => "Fred Flintstone"]); | ||
|
||
$this->assertEquals("2", count($customer->errors["email"])); | ||
|
||
\VCR\VCR::eject(); | ||
\VCR\VCR::turnOff(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/fixtures/iugu_customer_should_not_create_a_customer_without_email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
- | ||
request: | ||
method: POST | ||
url: 'http://api.desenvolvimento/v1/customers' | ||
headers: | ||
Host: api.desenvolvimento | ||
Authorization: 'Basic ZGV2ZWxvcG1lbnRfYXBpX3Rva2VuOg==' | ||
Accept: application/json | ||
Accept-Charset: utf-8 | ||
User-Agent: 'Iugu PHPLibrary' | ||
Accept-Language: 'pt-br;q=0.9,pt-BR' | ||
body: name=Fred+Flintstone | ||
response: | ||
status: | ||
http_version: '1.1' | ||
code: '422' | ||
message: 'Unprocessable Entity' | ||
headers: | ||
Server: nginx/1.13.8 | ||
Date: 'Wed, 28 Feb 2018 18:43:14 GMT' | ||
Content-Type: 'application/json; charset=utf-8' | ||
Transfer-Encoding: chunked | ||
Connection: keep-alive | ||
x-HandledBy: 'api/v1/customer#create' | ||
X-UA-Compatible: IE=Edge | ||
Cache-Control: no-cache | ||
X-Request-Id: a1870d2e11ef4af2b96fa5d5104652cf | ||
X-Runtime: '0.037351' | ||
Vary: Origin | ||
body: '{"errors":{"email":["n\u00e3o pode ficar em branco","n\u00e3o \u00e9 v\u00e1lido"]}}' |