GithubHelp home page GithubHelp logo

wordpressdev / codeigniter-handbook-vol-2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from efendibooks/codeigniter-handbook-vol-2

0.0 2.0 0.0 429 KB

The CodeIgniter Handbook - Volume Two - API Design

License: Other

codeigniter-handbook-vol-2's Introduction

CodeIgniter Handbook - Vol 2 - API Design

This repository is the complete code for Volume Two of The CodeIgniter Handbook by Jamie Rumbelow.

Installation / Setup

This small sample API--and associated code--is a regular CodeIgniter 2.1.2 application and requires PHP5.3 to run.

Use the following SQL schema dump to get a basic database set up and remember to configure config/database.php:

CREATE TABLE `api_clients` (
  `access_token` varchar(40),
  `shared_secret` varchar(40),
  `throttle_count` int(11),
  `throttled_at` datetime
) DEFAULT CHARSET=utf8;

INSERT INTO `api_clients` (`access_token`, `shared_secret`, `throttle_count`, `throttled_at`)
VALUES
	('4395dd07a3cfe84d9655bb2542907f3acd0024fe','3c697e1314808f56bd44bc5ccb4765607b433715',70,'2012-09-02 23:01:00');

CREATE TABLE `trackers` (
  `id` varchar(20),
  `name` varchar(200)
) DEFAULT CHARSET=utf8;

INSERT INTO `trackers` (`id`, `name`)
VALUES
	('ebook_downloads','eBook Downloads'),
	('website_visits','Website Visits');

CREATE TABLE `values` (
  `tracker_id` varchar(20),
  `value` varchar(200)
) DEFAULT CHARSET=utf8;

INSERT INTO `values` (`tracker_id`, `value`)
VALUES
	('website_visits','127.0.0.1'),
	('website_visits','::1'),
	('website_visits','0.0.0.0');

Unit Tests

The state of the unit tests have divulged somewhat from what is described in the book, in order to reflect a slightly more comprehensive set of tests.

Some configuration now occurs in phpunit.xml, which sets up a few variables and loads the bootstrap file. The bootstrap file defines an API\Tests\TestCase class which contains the request() method built in the book.

Install PHPUnit 3.6.12 and run the tests:

$ phpunit tests/trackers_test.php
PHPUnit 3.6.12 by Sebastian Bergmann.

Configuration read from /Users/jamierumbelow/Sites/efendibooks/codeigniter-handbook-vol-2-code/phpunit.xml

.....

Time: 1 second, Memory: 2.75Mb

OK (5 tests, 15 assertions)

$ phpunit tests/values_test.php
PHPUnit 3.6.12 by Sebastian Bergmann.

Configuration read from /Users/jamierumbelow/Sites/efendibooks/codeigniter-handbook-vol-2-code/phpunit.xml

..

Time: 1 second, Memory: 2.75Mb

OK (2 tests, 7 assertions)

See you for Volume Three!

codeigniter-handbook-vol-2's People

Contributors

jamierumbelow avatar mikedfunk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.