Skip to content

Commit

Permalink
Ads Type
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-moreno committed Jan 10, 2017
1 parent 31bd22a commit bc5986f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Tests/DocumentXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function test_general_xml()
{
$ad = (new Ad)
->setId('1')
->setAdsType('premium')
->setCity('Córdoba')
->setContent('Nokia 1100')
->setDistrict((new District)->setDistrict('Nueva Córdoba')->setZone('centro'))
Expand Down Expand Up @@ -75,6 +76,7 @@ public function test_vehicle_xml()
{
$vehicle = (new Vehicle)
->setId('11111111')
->setAdsType('premium')
->setCity('Córdoba')
->setColor('champagne')
->setConfort('aire acondicionado, stereo dvd, vidrios polarizados')
Expand Down
3 changes: 3 additions & 0 deletions Tests/Entity/AdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function test_getters_and_setters_ok()
$test_phone = new Phone;
$this->assertEquals($ad, $ad->setId('test_id'));
$this->assertEquals('test_id', $ad->getId());
$this->assertEquals($ad, $ad->setAdsType('test_ads_type'));
$this->assertEquals('test_ads_type', $ad->getAdsType());
$this->assertEquals($ad, $ad->setCity('test_city'));
$this->assertEquals('test_city', $ad->getCity());
$this->assertEquals($ad, $ad->setContent('test_content'));
Expand Down Expand Up @@ -63,6 +65,7 @@ public function requiredValueDataProvider()
{
return [
['Id', 'id'],
['AdsType', 'ads_type'],
['City', 'city'],
['Content', 'content'],
['Email', 'email'],
Expand Down
3 changes: 3 additions & 0 deletions Tests/Entity/VehicleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function test_getters_and_setters_ok()
$test_district = new District;
$this->assertEquals($vehicle, $vehicle->setId('test_id'));
$this->assertEquals('test_id', $vehicle->getId());
$this->assertEquals($vehicle, $vehicle->setAdsType('test_ads_type'));
$this->assertEquals('test_ads_type', $vehicle->getAdsType());
$this->assertEquals($vehicle, $vehicle->setCity('test_city'));
$this->assertEquals('test_city', $vehicle->getCity());
$this->assertEquals($vehicle, $vehicle->setColor('test_color'));
Expand Down Expand Up @@ -93,6 +95,7 @@ public function requiredValueDataProvider()
{
return [
['Id', 'id'],
['AdsType', 'ads_type'],
['City', 'city'],
['Content', 'content'],
['Email', 'email'],
Expand Down
1 change: 1 addition & 0 deletions Tests/xml_samples/general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
<picture><![CDATA[http://www.redusers.com/noticias/wp-content/uploads/2015/03/1100Nokia-650x450.jpg]]></picture>
</pictures>
<modify><![CDATA[2016-01-01 00:00:00]]></modify>
<ads_type><![CDATA[premium]]></ads_type>
</ad>
</data>
1 change: 1 addition & 0 deletions Tests/xml_samples/vehicle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<picture><![CDATA[http://www.sudominio.com/image.jpg]]></picture>
</pictures>
<modify><![CDATA[2013-04-10 15:40:05]]></modify>
<ads_type><![CDATA[premium]]></ads_type>
<modelo><![CDATA[4043]]></modelo>
<recibe_menor><![CDATA[si]]></recibe_menor>
<usado_anio><![CDATA[2005]]></usado_anio>
Expand Down
7 changes: 6 additions & 1 deletion resources/config/serializer/Zephia.LaVozFeed.Entity.Ad.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
Zephia\LaVozFeed\Entity\Ad:
access_type: public_method
accessor_order: custom
custom_accessor_order: [id, type, title, content, region, city, phone, email, operation, status, price, payment, district, pictures, modify]
custom_accessor_order: [id, type, title, content, region, city, phone, email, operation, status, price, payment, district, pictures, modify, ads_type]
exclusion_policy: NONE
properties:
id:
type: "string"
ads_type:
type: "string"
accessor:
getter: getAdsType
setter: setAdsType
city:
type: "string"
content:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Zephia\LaVozFeed\Entity\Vehicle:
access_type: public_method
accessor_order: custom
custom_accessor_order: [id, type, title, content, region, city, phone, email, operation, status, price, payment, district, pictures, modify, model, receives_lesser_value, year, kilometers, fuel, version, doors, transmission, segment, color, confort, security]
custom_accessor_order: [id, type, title, content, region, city, phone, email, operation, status, price, payment, district, pictures, modify, ads_type, model, receives_lesser_value, year, kilometers, fuel, version, doors, transmission, segment, color, confort, security]
exclusion_policy: NONE
properties:
color:
Expand Down
33 changes: 33 additions & 0 deletions src/Entity/Ad.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class Ad extends Entity
*/
private $id = '';

/**
* @var string
*/
private $ads_type = '';

/**
* @var string
*/
Expand Down Expand Up @@ -123,6 +128,34 @@ public function setId($id)
return $this;
}

/**
* Get Ads Type
*
* @return string
*/
public function getAdsType()
{
if (empty($this->ads_type)) {
throw new LogicException(
sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'ads_type')
);
}
return $this->ads_type;
}

/**
* Set Ads Type
*
* @param string $ads_type
*
* @return Ad
*/
public function setAdsType($ads_type)
{
$this->ads_type = $ads_type;
return $this;
}

/**
* Get City
*
Expand Down

0 comments on commit bc5986f

Please sign in to comment.